I believe I'm having a similar issue on Postgres 8.1. Here's the setup:
Hibernate tools 3.2 b7
Postgres 8.1.3
postgresql-8.1-407.jdbc3.jar
All other jars from tools package mentioned above
I first tried running this via ant, the gui version in eclipse didn't work either.
Here's the DDL for the many-to-many table:
Code:
CREATE TABLE conf.scaninst_sensorloc
(
scaninst_id int4 NOT NULL,
sensorloc_id int4 NOT NULL,
CONSTRAINT scaninst_sensorloc_pkey PRIMARY KEY (scaninst_id, sensorloc_id),
CONSTRAINT fk_scaninst_sensorloc FOREIGN KEY (scaninst_id)
REFERENCES conf.scaninst (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION,
CONSTRAINT fk_sensorloc_scaninst FOREIGN KEY (sensorloc_id)
REFERENCES conf.sensorloc (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITHOUT OIDS;
(the tables on each end are very simple- just the pk and a few fields.
Here's the relevant code that was generated by the tools:
SensorLoc.java:
Code:
@ManyToMany(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY, mappedBy = "sensorlocs")
public Set<ScanInst> getScaninsts() {
return this.scaninsts;
}
ScanInst.java:
Code:
@ManyToMany(cascade = { CascadeType.ALL }, fetch = FetchType.LAZY, mappedBy = "scaninsts")
public Set<SensorLoc> getSensorlocs() {
return this.sensorlocs;
}
So of course, when I try to run the hbm2ddl ant task (with an annotations config), I get the following error:
Code:
org.hibernate.AnnotationException: Illegal use of mappedBy on both sides of the relationship: com.lumeta.ips.report.data.model.conf.SensorLoc.scaninsts
Suggestions welcome if there's something I'm doing wrong, but seems to me like this might be a bug. If anyone wants me to run with -verbose or other tags, I'd be happy to do so.
Also- it'd be nice to not have to fix these mappings by hand (yes, I wish I were familiar with the hibernate code base, but I'm not... yet... :)
Thanks,
- Bucky