Thanks. It worked in all but one case.
I have entities called Policy, Producer, Branch and UserPolicyType
of these, Policy and Producer are inserted into the table whereas Branch and UserPolicyType are masters.
I notice that a Producer is being populated for each Policy and hence getting duplicate rows of Producer.
I am placing the snippet below.
Request help to resolve the problem.
Thanks
Code:
@Entity
@Table(name="CSENTRYPOLICY")
public class CSentryPolicy implements Serializable{
@Id @GeneratedValue (strategy=GenerationType.SEQUENCE , generator="POLICY_SEQ" ) //omitted rest for clarity
int iPolicyID;
@ManyToOne(//omitted rest for clarity)
@JoinColumn(name="SPRODUCERNBR", referencedColumnName="SPRODUCERNBR",nullable=false)
CSentryProducer producer;
@OneToOne(//omitted rest for clarity)
@JoinColumn(name="IADDRESSID", nullable=false)
CSentryAddress address;
@ManyToOne(//omitted rest for clarity)
@JoinColumns({
@JoinColumn(name="CATNBR", referencedColumnName="IUSERPOLICYTYPEID"),
@JoinColumn(name="POTYPE", referencedColumnName="SPOLICYPRINTTITLE" )
})
CSentryUserPolicyType policyType;
.
.
.
@Table(name="CSENTRYPRODUCER", uniqueConstraints={@UniqueConstraint(columnNames={"SPRODUCERNBR"})})
public class CSentryProducer implements Serializable{
@Id
@GeneratedValue(//omitted rest for clarity)
int iProducerID;
@OneToOne(cascade=CascadeType.ALL)
@JoinColumn(name="IADDRESSID")
CSentryAddress address;