I'm using Glassfish 3.1.2 and PostgreSQL. I've removed some unimportant
fields in my tables to simplify and show the pieces I'm trying to figure out.
The Item, Label, and Register records already exists in the database, so I'm
trying to add a Report which references Label and Register. By my
understanding, this is a many-to-one relationship as there can be many
Reports to one Label as well as many reports to one Register. The problem is
I can't get the orm.xml to map this correclty. Can anyone help out on what
the XML should be for the Report entity mapping? Here's my PostgreSQL setup.
CREATE SEQUENCE reg_seq START 1000; CREATE TABLE Register ( id INTEGER
DEFAULT NEXTVAL('reg_seq') PRIMARY KEY, clerk VARCHAR(32) NOT NULL ); CREATE
SEQUENCE item_seq START 1000; CREATE TABLE Item ( id INTEGER DEFAULT
NEXTVAL('item_seq') PRIMARY KEY, name VARCHAR(32) NOT NULL, description
VARCHAR(128) DEFAULT NULL ); CREATE SEQUENCE label_seq START 1000; CREATE
TABLE Label ( id INTEGER DEFAULT NEXTVAL('label_seq') PRIMARY KEY, item_id
INTEGER REFERENCES Item (id), vendor VARCHAR(32) DEFAULT NULL, msg
VARCHAR(64) DEFAULT NULL ); CREATE SEQUENCE report_seq START 1000; CREATE
TABLE Report ( id INTEGER DEFAULT NEXTVAL('report_seq') PRIMARY KEY, label_id
INTEGER REFERENCES Label (id), reg_id INTEGER REFERENCES Register (id), time
TIMESTAMP DEFAULT NULL ); This is my Report entity. public class Report
implements Serializable { private Integer id; private Label label; private
Register register; public Report() { } public Integer getId() { return
this.id; } public void setId(Integer id) { this.id = id; } public Label
getLabelId() { return this.labelId; } public void setLabelId(Label labelId) {
this.labelId = labelId; } //... getters & setters for other fields } And
here's my orm.xml. allocation-size="1"/> allocation-size="1"/>
--
[Message sent by forum member 'rrlangly']
View Post: http://forums.java.net/node/890519