This content has been marked as final.
Show 4 replies
-
1. Re: Inserting into primary and secondry table using bean
trickyvail Jul 30, 2007 11:23 AM (in response to kaviarasu)This is a question for the EJB3 forum.
Yes this is easy to do without using a trigger.
You could map as a One-to-One Unidirectional or a One-to-One Bidirectional.
e.g. One-to-One Unidirectional@Entity public class Employee { private int id; private Address address; @Id @Column(name = "eno") @GeneratedValue public int getId() { return this.id; } @OneToOne @PrimaryKeyJoinColumn public Address getAddress() { return address; } }
-
2. Re: Inserting into primary and secondry table using bean
kaviarasu Aug 2, 2007 3:33 AM (in response to kaviarasu)hi i cant able to understand ur schema
i have pasted the sample coding
can u say how to insert in this, i created two tables Table 1 and table 2. this code is generated by exadel@Entity public class Table1 implements Serializable { @Id private BigDecimal no; @OneToMany(mappedBy="no") private Set<Table2> table2Collection; private static final long serialVersionUID = 1L; public Table1() { super(); } public BigDecimal getNo() { return this.no; } public void setNo(BigDecimal no) { this.no = no; } public Set<Table2> getTable2Collection() { return this.table2Collection; } public void setTable2Collection(Set<Table2> table2Collection) { this.table2Collection = table2Collection; } }
Table 2@Entity public class Table2 implements Serializable { @Id private BigDecimal eno; @ManyToOne @JoinColumn(name="NO") private Table1 no; private static final long serialVersionUID = 1L; public Table2() { super(); } public BigDecimal getEno() { return this.eno; } public void setEno(BigDecimal eno) { this.eno = eno; } public Table1 getNo() { return this.no; } public void setNo(Table1 no) { this.no = no; } }
thank you
ragrds
kaviarasu -
3. Re: Inserting into primary and secondry table using bean
trickyvail Sep 13, 2007 11:53 AM (in response to kaviarasu)I'm not sure I understand your question correctly, but I think you are asking how to have the primary keys generated for you? Your entity beans do not have the @GeneratedValue annotation on their id fields. This may be what you need to explore.
-
4. Re: Inserting into primary and secondry table using bean
kaviarasu Sep 14, 2007 12:53 AM (in response to kaviarasu)Hi thanks for ur reply
it worked atlast