Search code examples
javahibernatejpahql

using hibernate, how to write @OneToMany(mappedBy="somethingFkId") in xml?


does anyone know how to write @OneToMany(mappedBy="customers") in xml?

I searched everywhere but didn't find anyone who write mappedBy in xml. I need to map one-to-many that mappedBy other column in other existing entity without creating new entity(like join table) or new collumn. I don't have the right to add another column or table. I know the way to do it is using hibernate anotation @OneToMany(mappedBy="customers").

But how to write it in xml? because my other project use java 1.4 that doesn't support annotation, so i can't use that @OneToMany(mappedBy="customers").

Something like this in java 1.6 :

in table B:

@OneToMany(mappedBy="bId", cascade = CascadeType.DETACH)
private Set<AJoinB> testJoins = new HashSet<AJoinB>();

in table AJoinB :

@Column(name = "B_ID", nullable = false)
private Long bId;

Solution

  • Here there is an example of using one-to-many tag in xml http://www.mkyong.com/hibernate/hibernate-one-to-many-relationship-example/