-->
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: Length of char attr's lost: sess.createSQLQuery("...&qu
PostPosted: Wed Jun 06, 2007 10:26 am 
Newbie

Joined: Wed Jun 06, 2007 10:07 am
Posts: 1
session.createSQLQuery("select......").list() appears to truncate char attributes to a single character.

Is this a known issue?
If a bug, are there generic workarounds? I have to do a fair amount of bulk dml, sometimes on tables unknown to hibernate, and this bug can be a real stumbling block.


I'm using Hibernate 3.2.2, here's all the relevant log data:

- Hibernate 3.2.2
- hibernate.properties not found
- Bytecode provider name : cglib
- using JDK 1.4 java.sql.Timestamp handling
- configuring from resource: /hibernate.cfg.xml
- Configuration resource: /hibernate.cfg.xml

...........

- RDBMS: Microsoft SQL Server, version: Microsoft SQL Server 2000 - 8.00.2039 (Intel X86)
May 3 2005 23:18:38
Copyright (c) 1988-2003 Microsoft Corporation
Enterprise Edition on Windows NT 5.2 (Build 3790: Service Pack 1)


>>>>>>>>>> we create a table:

Hibernate: create table #t (a char(10), b varchar(10))


................

>>>>>>>>>>>> we put some values into the table:

Hibernate: insert #t values ('foo', 'bar')
Hibernate: insert #t values ('mint', 'twinky')

>>>>>>>>>>>> we retrieve values and print them
Hibernate: select * from #t
f, bar
m, twinky


The java code used is:


//PersistenceUtil is just a global that acquires/release/holds sessions
Session s = PersistenceUtil.currentSession();

s.createSQLQuery("create table #t (a char(10), b varchar(10))").executeUpdate();

s.createSQLQuery("insert #t values ('foo', 'bar')").executeUpdate();

s.createSQLQuery("insert #t values ('mint', 'twinky')").executeUpdate();

for (Object o : s.createSQLQuery("select * from #t").list()){
Object[] oa = (Object[]) o;
System.out.println(oa[0] + ", " + oa[1]);
}


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.