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: Using TableGenerator within an EmbeddedId
PostPosted: Tue Jan 13, 2009 11:39 am 
Newbie

Joined: Tue Aug 07, 2007 3:19 am
Posts: 5
I have an EmbeddedId class which consists of 4 columns. 3 of these columns are assigned values while the fourth column should be value retrieved from a sequence table.


Code:
@Embeddable
public class DistributionId extends DirectId {
    private static final long serialVersionUID = -1693326833940025204L;
   
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "CDDT_PART_GRP_ID")
    private Integer groupId;
   
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "CDDT_CUST_AGR_ID")
    private Integer agreementSequenceNumber;
   
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "CDDT_MSG_TYP_ID")
    private Integer messageTypeId;
   
    @TableGenerator(
            name = "CDDT_SEQ_GEN",
            table = "SEQ_NUMBER",
            pkColumnName = "SEQN_COLUMN_NAME",
            valueColumnName = "SEQN_NUMBER",
            pkColumnValue = "CDDT_CDDT_SEQ",
            allocationSize = 1
    )
    @GeneratedValue(strategy = GenerationType.TABLE, generator = "CDDT_SEQ_GEN")
    @Column(name = "CDDT_CDDT_SEQ")
    private Integer distributionSequence;


I am using a TableGenerator on another class with only one Id and that one works fine. How can I get the generator to retrieve a new value from the database table and use the other as assigned?

I am using Hibernate version 3.3.1 and this has support for a generator on a single composite-key. How can I get this to work with Annotations?


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.