The two cases below seem correct the way you mention. But I want to know about a 3rd case - uni direction Many to One. JPA (as well as the hibernate link you showed in section 2.2.5.2) has the @ManyToOne. Can we actually model a Many to One uni-directional relation? And if we can, how would I figure out the source's multiplicity to correctly put the annotation. I think it seems we cant really model the many to one in dsl. In UML one could though.
There is another missing information about the "owner" side. This is also mentioned in the hibernate link below in section 2.2.5.1...If we have a bi-directional one to one association, then one end gets the @JoinColumn and the other end gets the mappedBy. The former has to be put on the owner side (or the side that holds the FK column), but there is no meta information coming from the sculptor dsl to signify who is the owner. Not to mention the DDL generated by the bi-directional one to one case is incorrect. It generates two FK columns on both the end entities and treats both like isolated uni-directional one to one. So the DDL generated for A<-->B is like A-->B and B-->A. There is a FK from A to B and a FK from B to A. Which I think is incorrect. There has to be only one FK in the owner side, and thats the side that gets the @JoinColumn while the other end gets the mappedBy which signifies that this is the same one to one relation and no a different isolated one. I noticed in the contraints check one to one bidirectional wasnt allowed. Was this the reason? Thanks. Patrik Nordwall wrote: > > Take a look at 2.2.5.3.2.2. Unidirectional in > http://www.hibernate.org/hib_docs/annotations/reference/en/html/entity.html > > You have two cases for unidirectional. > 1. target has cardinality many. I think @OneToMany together with > @JoinTable should be used. > 2. target has cardinality 1 (not many). I think @OneToOne together with > @JoinColumn can be used. > > I don't think you have to consider the source cardinality. > > /Patrik > > > Darth wrote: >> >> How come JPA requires then to put different annotations based on the >> source's cardinality? >> > > I don't know, but I guess > -- View this message in context: http://www.nabble.com/How-to-figure-out-if-a-relation-%28reference%29-is-Bi-Directional--tp18099001s17564p18120771.html Sent from the Fornax-Platform mailing list archive at Nabble.com. ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ Fornax-developer mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/fornax-developer
