-->
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.  [ 2 posts ] 
Author Message
 Post subject: Problems mapping an auto incremented field
PostPosted: Fri Jan 12, 2007 7:23 am 
Newbie

Joined: Thu Jan 11, 2007 1:57 pm
Posts: 9
Hello all!

I'm new in Hibernate annotations. I have a problem mapping an Entity.

Description:

I have an Entity with an EmbeddedId:

@EmbeddedId
@AttributeOverrides( {
@AttributeOverride(name="uuid", column = @Column(name=PAYMENT_TRANSACTION_ID) ),
})
private EntityPK pk = new EntityPK();

This entity also has a field, that should be auto incremented by the database.

@Column(name=PAYMENT_TRANSACTION_INVOICENR, length=9, insertable=false, updatable=false, unique=true)
@Generated(value=GenerationTime.INSERT)
private int invoicenr;


The Table daclaration should be something like that:

CREATE TABLE PAYMENTTRANSACTION ( .... (other column definitions)...,
invoicenumber INT(9) NOT NULL AUTO_INCREMENT KEY) AUTO_INCREMENT = 100000000;

could somebody help me? I was trying it with:
1.-
@Generated(value=GenerationTime.INSERT)
2.-
@Column(length=9, unique=true, ...)
@GeneratedValue(strategy=GenerationType.AUTO)

but it didnt work.

greetings,


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jan 12, 2007 2:06 pm 
Newbie

Joined: Thu Jan 11, 2007 1:57 pm
Posts: 9
i have used:
@Column(name=PAYMENT_TRANSACTION_INVOICENR, columnDefinition="INT(10) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT UNIQUE", length=9)
private long invoicenr;

this works but it looks like:

000000001
000000002
000000003
000000004
etc.


i would like to get the AUTO_INCREMENT sequence with:
100000000, so that the values of the columns would be:

100000001
100000002
100000003
100000004
etc.

i can make that when i configure the table with AUTO_INCREMENT=100000000, that means for example:

create table t3 (c INT(10) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT UNIQUE, txt VARCHAR(4) DEFAULT 'FAKE') AUTO_INCREMENT=1000000000;

There is a way to do that with hibernate with an annotation?

Please, help me!


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

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.