Refer:
http://www.java2s.com/Tutorial/Java/0355__JPA/OneToManyJoinTableSetup.htm
Hi all,
On further investigation, I'm pretty sure that what I'm trying to do
is legit. It's a unidirectional oneToMany and I can see some examples
of using JPA to set it up:
http://www.java2s.com/Tutorial/Java/0355__JPA/OneToManyJoinTableSetup.htm
http://tadtech.blogspot.com/2007/09/hibernate-annotation-one-to-many-join.html
In Hibernate, for example, unidirectional appears to be the preferred
option.
I thought it might be that the Car had to specify all the details of
the join, so I tried this:
@OneToMany(cascade=CascadeType.ALL)
@PrivateOwned
@JoinTable(name="car_wheels",
joinColumns= {
@JoinColumn(name="car_id", referencedColumnName="id")
},
inverseJoinColumns = {
@JoinColumn(name="wheel_id", referencedColumnName="id")
}
)
private List wheels = new ArrayList();
...but I still get an exception:
java.lang.RuntimeException: Null Getter for: TestWheel.test_car
at
com.avaje.ebean.server.deploy.BeanProperty.(BeanProperty.java:
276)
at
com.avaje.ebean.server.deploy.BeanPropertyAssoc.(BeanPropertyAssoc.java:
93)
at
com.avaje.ebean.server.deploy.BeanPropertyAssocOne.(BeanPropertyAssocOne.java:
69)
at
com.avaje.ebean.server.deploy.meta.DeployBeanPropertyLists.(DeployBeanPropertyLists.java:
83)
at
com.avaje.ebean.server.deploy.BeanDescriptor.(BeanDescriptor.java:
425)
at
com.avaje.ebean.server.deploy.BeanDescriptorManager.readEntityRelationships(BeanDescriptorManager.java:
587)
at
com.avaje.ebean.server.deploy.BeanDescriptorManager.deploy(BeanDescriptorManager.java:
245)
at
com.avaje.ebean.server.core.InternalConfiguration.(InternalConfiguration.java:
134)
at
com.avaje.ebean.server.core.DefaultServerFactory.createServer(DefaultServerFactory.java:
168)
at
com.avaje.ebean.server.core.DefaultServerFactory.createServer(DefaultServerFactory.java:
104)
at
com.avaje.ebean.server.core.DefaultServerFactory.createServer(DefaultServerFactory.java:
67)
at com.avaje.ebean.EbeanServerFactory.create(EbeanServerFactory.java:
63)
at com.avaje.ebean.Ebean$ServerManager.getWithCreate(Ebean.java:226)
at com.avaje.ebean.Ebean$ServerManager.get(Ebean.java:213)
at com.avaje.ebean.Ebean$ServerManager.access$1(Ebean.java:203)
at com.avaje.ebean.Ebean.getServer(Ebean.java:277)
So... I'm starting to think this is a bug, or missing functionality in
Ebean? Or have I misunderstood? I'm using 2.3.
Thanks,
Alastair