-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: JPA JoinTable annotation with sequence generator
PostPosted: Fri Jun 25, 2010 2:17 pm 
Newbie

Joined: Fri Oct 26, 2007 9:30 am
Posts: 11
Hi,
I'm using JPA with an Oracle10g backend. I'm implementing a many-tomany relation ship using a join table:
tbl_job_type <-> tbl_join_job_type_tags <-> tbl_tags

I'm not sure how to include the information regarding sequence generator in my annotation. I.e. when I add a tag to a job_type my persist call fails because the record to be persisted on tbl_join_job_type_tags was not initialized with an id.

Here is my definition on the job_types side:
@Table(name = "XEDOC_ADMIN.TBL_JOB_TYPES")
public class JobType implements java.io.Serializable {

@SuppressWarnings("unused")
@Column(name="OBJ_VERSION")
private int version;

private Integer id;
.... snip ...
private UserDomain userOwner;
private UserDomain userModifier;
private SortedSet<Tag> tags;

.... snip ...

@ManyToMany()
@JoinTable(name = "TBL_JOIN_JOB_TYPE_TAGS",
joinColumns = {
@JoinColumn(name="JOB_TYPE_ID")
},
inverseJoinColumns = {
@JoinColumn(name="TAG_ID")
})
@Sort(type = SortType.COMPARATOR, comparator = TagComparator.class)
public SortedSet<Tag> getTags() {
return tags;
}

The error: java.sql.BatchUpdateException: ORA-01400: cannot insert NULL into ("XEDOC_ADMIN"."TBL_JOIN_JOB_TYPE_TAGS"."ID")

How can I tell JPA to use the a sequence generator to obtain a unique ID for records to be created?



TIA

Jacques


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.