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: ColumnTransformer bugged?
PostPosted: Sun Feb 20, 2011 2:26 pm 
Newbie

Joined: Tue Oct 19, 2010 9:18 am
Posts: 7
Hello folks,

i have to read in a Navision database (SQL-Server 2008). Doing so i have to get around the sql-variant-Datatype that is not supported anymore by the official JDBC driver.
So i added the following annotation to my attribute (its read only):
Code:
@Column(name="Hausnr_", length=30, nullable=false)
@ColumnTransformer(read="CAST([Hausnr_] AS NVARCHAR(30))")
private String hausnr = "";

in this case it works very well, hibernate produced following statement:
"CAST(vu_person0_.[Hausnr_] AS NVARCHAR(30)) as Hausnr11_201_"...

but i think there is a deep flaw in it: CONVERT and CAST did not work in this case, because hibernate tries to replace some words in the inner braces with entity-attributes:
Code:
@Column(name="timestamp", nullable=false)
@ColumnTransformer(read="CAST([timestamp] AS INT)")
private int crc;

this results in following:
"CAST(vu_person0_.[timestamp] AS vu_person0_.INT) as timestamp6_201_"...
which of course will result in a database error, because there is no database type like xyz.INT.

Beside that i think it's a general error, anyone knows how to get around this?

Chris


Top
 Profile  
 
 Post subject: Re: ColumnTransformer bugged?
PostPosted: Sun Feb 20, 2011 2:45 pm 
Newbie

Joined: Tue Oct 19, 2010 9:18 am
Posts: 7
i found out that you can get around this if you put "INT" in quotes. SQL-Server ignores it and hibernate does not try to replace it.
Bug anyway in my opinion.


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.