-->
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.  [ 3 posts ] 
Author Message
 Post subject: Mapping a fixed character field
PostPosted: Mon Oct 11, 2004 5:00 am 
Newbie

Joined: Tue Oct 05, 2004 4:56 am
Posts: 7
Hi all,

I've got a db table (Oracle9) which has a fixed character field as PK (trn_id CHAR(16)). Problem is that the values in this field are not always 16 characters long which means Oracle adds as many spaces as necessary to get to 16. I've now done a Hibernate mapping of this table using the string type to map this field. Queries do work but only if i manually add the spaces to the value before setting it.

Does not work:
Transaction t = (Transaction) trnQuery.setParameter("tnid","04218361151C4WR",Hibernate.STRING).uniqueResult();

Does work:
Transaction t = (Transaction) trnQuery.setParameter("tnid","04218361151C4WR ",Hibernate.STRING).uniqueResult();

I also tried using a custom type which trims the value but it seems the methods of this CustomType are never called when setting a query parameter.

Any hints how to solve such mappings?

thx
Roman


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 11, 2005 3:41 am 
Newbie

Joined: Tue Oct 11, 2005 3:34 am
Posts: 2
Does anyone know solution of this problem?
I have a same problem

Works
Query query = session.createQuery("from User where login = '" + login.toUpperCase() + "'");

Doesn't work
Query query = session.createQuery("from User where login = ?");
query.setString(0, login.toUpperCase());

,where login is char(30) (Oracle DB)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 12, 2005 1:36 am 
Newbie

Joined: Tue Oct 11, 2005 3:34 am
Posts: 2
up


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