Using @JoinColumnsOrFormulas and mappedBy

I have a problem with the following code:

FiBean table:

@JoinColumnsOrFormulas({ 
    @JoinColumnOrFormula(column = @JoinColumn(name = "TRI", referencedColumnName = "TRI", nullable = false, insertable = false, updatable = false)),
    @JoinColumnOrFormula(formula = @JoinFormula(value = "USER1", referencedColumnName = "CODE"))
})
private UserBean user1;

      

UserBean table:

@OneToMany(mappedBy="user1", cascade={CascadeType.PERSIST, CascadeType.MERGE})
private Collection<FiBean> listeUser1;

      

Then this error occurs:

Caused by: java.lang.ClassCastException: org.hibernate.mapping.Formula
at org.hibernate.cfg.annotations.TableBinder.bindFk(TableBinder.java:352)
at org.hibernate.cfg.annotations.CollectionBinder.bindCollectionSecondPass(CollectionBinder.java:1423)
at org.hibernate.cfg.annotations.CollectionBinder.bindOneToManySecondPass(CollectionBinder.java:733)
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:666)
at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:619)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:66)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1221)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:383)
at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1206)
at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:1459)
at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:193)

      

Hibernate v3.5.6 JDK 5 Tomcat 5.5

I found a workaround here ( https://forum.hibernate.org/viewtopic.php?f=1&t=1010559 by removing mappedBy on the UserBean) but why doesn't this code work?

+3
java hibernate jpa one-to-many many-to-one


source to share


No one has answered this question yet

Check out similar questions:

459
What's the difference between @JoinColumn and mappedBy when using JPA @OneToMany association
151
Can someone explain mappedBy in sleep mode?
25
@OneToMany displays cards on _____
3
does mappedBy refer to class name or table name?
1
mappedBy as the field to which the ratio belongs
1
Why Hibernate ManyToOne bind to them?
0
@ManytoMany annotation issue org.hibernate.MappingException: Unable to find physical table 'producto'
0
Thrown by: org.hibernate.AnnotationException: mappedBy is referencing an unknown target object property: jpa + springboot
0
Seeing that the "associated error" Column Name (ID) ... does not map to one property "with a 1-M relationship after adding a composite key to side" 1 "
0
Hibernate One-to-Many Mapping problem using @JoinTable



All Articles
Loading...
X
Show
Funny
Dev
Pics