-->
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.  [ 4 posts ] 
Author Message
 Post subject: What generator class needs to be used?
PostPosted: Tue Feb 15, 2005 1:27 am 
Newbie

Joined: Fri Feb 11, 2005 6:12 pm
Posts: 6
I have a table as below

create table BUYER (
BUYERCODE VARCHAR2(255) not null,
BUYERNAME VARCHAR2(50) not null,
primary key (BUYERCODE)
);

The hbm file is as below

<class name="com.arch.db.vo.Buyer" table="BUYER">
<id name="buyerCode" column="BUYERCODE" type="string" unsaved-value="null">
<generator class="??????"/>
</id>
<property name="buyerName" column="BUYERNAME" type="string" length="50" not-null="true"/>
</class>

What class should I use in the generator tag as the column buyerCode[primary key] is a string?

Kindly let me know at the earliest

Thanks
Saravanan


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 15, 2005 3:52 am 
Newbie

Joined: Wed Sep 01, 2004 9:04 am
Posts: 18
Location: Enschede, Netherlands
Read section 5.1.4.1 of the Hibernate reference. I think you are looking for uuid.hex or uuid.string.

http://www.hibernate.org/hib_docs/reference/en/html/mapping.html#mapping-declaration-id-generator


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 15, 2005 3:48 pm 
Newbie

Joined: Fri Feb 11, 2005 6:12 pm
Posts: 6
Buyer obj = new Buyer();
obj.buyerCode("N12345");
obj.buyerName("SampleName");
hda.storeObj(obj);

When I tried uuid.string the record in the table was inserted with the no value for the buyercode [It was empty]

When I tried uuid.hex the record in the table was inserted with the a value for the buyercode as 8a80800102176cdc0102176cfa850001

In either case i was not able to get my value that 'N12345'. So what generater class should I use to get this inside the column


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 15, 2005 3:56 pm 
Newbie

Joined: Fri Feb 11, 2005 6:12 pm
Posts: 6
It worked when I tried with the genertor class as "assigned"

Thanks for the link


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.