-->
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: Composite key with strange results in DB
PostPosted: Sat Oct 20, 2007 6:37 am 
Newbie

Joined: Wed May 16, 2007 11:41 am
Posts: 8
Hi, I'm trying to persist a composite-id class which is composed out 2 fields as primary key. This isn't the first time I'm using composite class, so I think how it should work. I have used it on the same database, except this is another table.

This time I'm facing a very strange problem: When I inspect my object in Eclipse, every value on the object that's going to be persisted looks good (=every value is correctly filled up, the primary key object is mapped to the genaral object).

After I save() my object, the log4j logging looks like this: INSERT INTO xxx (aa,bb,cc,dd) values(?,?,?,?)
binding parameter 1 to 1234
binding parameter 2 to 7845101
binding parameter 3 to 2007-01-10 12:14:45
binding parameter 4 to 2006-10-10 12:45:45

Now the strange this is, when I look in my database value 'bb' doesn't look like '7845101' but is another randomly(?) value like '@45e2df'. All other values - even the other PK - is filled out correctly

I thought the values which is shown in the logging is actually inserted. Do you have any idea what can be wrong?

Hibernate version: 3.0.5 using it with Spring 1.2.8

Name and version of the database you are using: Oracle 9i

Thx for any help!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 22, 2007 9:51 am 
Newbie

Joined: Wed May 16, 2007 11:41 am
Posts: 8
Hi,

We managed to solve this issue by adding <sql-insert> to the mapping file of the table being used.

As far as we can see, we think the string filled with integers is interpreted as an integer-value, and thus using it's being used like an integer.

We sorted this out, by adding <sql-insert> and a TO_CHAR to the problem column like this in our .hbm.xml:

<sql-insert>
INSERT INTO TABLE(AA, BB, CC, DD,EE)
VALUES ( ?, ?,?,TO_CHAR(?),?)
</sql-insert>

If someone has a better explanation, I'm happy to get it!


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.