Hi all,
I have a strange problem with an entity relation. I have a manyToOne relation between an
entity called "Address" and and entity called "Country". Address
should only use existing Countries. If Country enitity doesn't exists it should throw
a kind of ForeignKeyException.
Now my Problem:
If I update the Address with another Country (which is not in den DB yet), the Address
entity is only updated in the object instance. The database entry is unchanged. But now I
have a new entry in my Country table?? I expected an exception not a new entry.
If I have a Country object and updates my Address, the address row in the db is also not
changed?
Here some code fragments:
| public class Address implements Serializable {
|
| @Id
| @Column(name = "id", nullable = false)
| private Integer id;
|
| ...
|
| @ManyToOne(fetch=FetchType.LAZY,cascade=CascadeType.ALL)
| @JoinColumn(name = "isocodecountry", referencedColumnName =
"isocode")
| private Country isocodecountry;
|
| ...
|
| public class Country implements Serializable {
|
| @Id
| @Column(name = "isocode", nullable = false, insertable=false,
updatable=false)
| private String isocode;
|
| ....
|
My system:
JBoss 4.0.5 GA (from Installer) with SEAM 1.1.0-CR1 on Win XP with a Postgre 8.1.5 DB.
I hope some can help me.
Regards
Marco
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3989979#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...