|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Toplink cascade with embedded id and autoincrementhi,
Im having this problem with my project: public class Meeting implements Serializable { private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Basic(optional = false) @Column(name = "ID") private Integer id; .... with relationship @OneToMany(cascade = CascadeType.ALL, mappedBy = "meeting1", fetch = FetchType.LAZY) private Collection<Document> documentCollection; and the Document entity: public class Document implements Serializable { private static final long serialVersionUID = 1L; @EmbeddedId protected DocumentPK documentPK; .... @JoinColumn(name = "Meeting", referencedColumnName = "ID", insertable = false, updatable = false) @ManyToOne(optional = false, cascade=CascadeType.ALL) private Meeting meeting1; and documentPK @Embeddable public class DocumentPK implements Serializable { @Basic(optional = false) @Column(name = "ID") private Integer id; @Basic(optional = false, fetch=FetchType.EAGER) @Column(name = "Meeting", nullable=false) private Integer meeting; problem is when i create a meeting and add some documents to it I get the exception: Exception [TOPLINK-4002] (Oracle TopLink Essentials - 2.1 (Build b60e-fcs (12/23/2008))): oracle.toplink.essentials.exceptions.DatabaseException Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'Meeting' cannot be null Error Code: 1048 Call: INSERT INTO DOCUMENT (Name, Note, File, FileName, ID, Meeting) VALUES (?, ?, ?, ?, ?, ?) bind => [null, null, [B@fbb498, j2ee_books.part2.rar, null, null] Query: InsertObjectQuery(org.ipo.mm.ejb.entities.Document[documentPK=org.ipo.mm.ejb.entities.DocumentPK[id=null, meeting=null]]) usgin glassfish v2, mysql 5.0 on fedora 10 any ideas? |
|
|
|
|
|
Re: Toplink cascade with embedded id and autoincrementThx a lot Chris, you explained it to me perfectly. Realy appreciate it.
I did use the solution you proposed, but i expected this to work to. I'm stuck with jpa 1. ![]() Will it work if I remove updatable and insertable annonation? I'll try!
|
| Free embeddable forum powered by Nabble | Forum Help |