-->
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: How to use one Column as Parameter for UserType
PostPosted: Wed May 04, 2011 10:06 am 
Newbie

Joined: Wed May 04, 2011 9:30 am
Posts: 2
I am mapping many table of legacy system and I have a problem about timezone requisite.

My Table has this situation below:

Table Operation:
Ref_local (String)
Ref_Type (Enum)
O_D_local (String)
O_D_type (Enum)
DateIni (Calendar)
.....
other Properties.

These five properties are PK. The legacy system uses the column Ref_local in order to discover the DateIni timezone. I would like to create a UserType that load Calendar in correct TimeZone Automatically. For this, I need to get the Ref_local column as part of mapping.

The First idea was:

Code:
@Column(name="Ref_local", insertable/updatable=false)
@Column(name="Data_ini")
@Type(...CalendarUserType...)
private Calendar dataIni;


But I can't mix updatable e not updatable column in mapping. If I let both columns as updatables, the mapping fail in other places (of course).

I tried to create a CompositeUserType but passing just one column. Inside, I could get the ResultSet and getColumn(ColumnName), but I fall in two problems.

1 - The Hibernate put a alias in column, so I can't to discover this alias in RunTime and I Can't get the value in resultset directly.
2 - Even I get the value, when I use the sessionImplementor to find the timezone using the column value, the current resultset is closed.

Are there any way to solve my problem. My workaround was put this code in a method PostLoad inside each entity but in this way, I spread the requisite in application and become hard to refactor in the future.

A "possible" solution could be I use "@Column" as Parameter in CustomType but I don't know if is possible.

Example:

Code:
@Column(name = "Data_ini")
@Type(type = CalendarUserType.NAME, parameters = @Parameter(name=CalendarUserType.COLUMN,value=@Column(name="Ref_local")))
private Calendar dataIni;


Any suggestion?


Top
 Profile  
 
 Post subject: Re: How to use one Column as Parameter for UserType
PostPosted: Fri May 06, 2011 7:17 am 
Newbie

Joined: Wed May 04, 2011 9:30 am
Posts: 2
No way in current version?


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.