Hi,

I have an EmailMessage Entity, which contains four collections, which all 
reference the same type of entity bean, which in my case represents an 
EmailAddress.

So I have an EmailMessage and inside 4 collections, all of which in turn store 
EmailAddress Entities for the email fields to, cc, bcc and replyTo.

I looked in the database and the table for the relationship looks like this:

---------  emailmessage_emailaddress ----------------
emailmessage_id bigint  NOT NULL
        
replyto_id bigint NOT NULL
bcc_id  bigint  NOT NULL
cc_id   bigint  NOT NULL
to_id   bigint  NOT NULL
-------------------------------------------------------------

If I create an EmailMessage and add one EmailAddress entity bean to one of the 
collections, then I get a contraint exception, because the "NOT NULL" 
constraint is violated.

How, can I set this up, so that this works? Is this possible at all?

Here are the 2 entity beans: 

-------------------------------------------------

@Entity
@Name("emailMessage")

public class EmailMessage implements Serializable
{
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  long id;

  @OneToOne(cascade = {CascadeType.ALL})
  EmailAddress from;

  @OneToMany(cascade = {CascadeType.ALL})
  Collection to = new ArrayList();

  @Temporal(TemporalType.TIMESTAMP)
  Date sentDate;

  @OneToMany(cascade = {CascadeType.ALL})
  Collection cc = new ArrayList();

  @OneToMany(cascade = {CascadeType.ALL})
  Collection bcc = new ArrayList();

  @OneToMany(cascade = {CascadeType.ALL})
  Collection replyTo = new ArrayList();

...
}

------------------------------------------------------------

@Entity
@Name("emailAddress")

public class EmailAddress implements Serializable
{
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  long id;
  
  String emailAddress;
  String name;
...
}



View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4002349#4002349

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4002349
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to