-->
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: legacy queries/mapping
PostPosted: Tue Jan 15, 2008 8:35 am 
Newbie

Joined: Tue Jan 15, 2008 7:57 am
Posts: 2
Hi,

Does hibernate support the ability to map one field to another field within the domain model and allow HQL queires to use the former.

Use Case for this would be where we have a huge set of HQL queries that use the current domain model.Non-trivial changes are made to that model.The large set of queries prevent us doing this in one go.We need to be abe to evolve the changes.We would also have third parties that would have written queries against the old model.

e.g.

class Account{
private String accountNumber
private String IBAN
}

we want to change this to

class Account{
private Set<AccountKey> keys
}

class AccountKey{
String accountId
KeyTypeEnum idType
}

Could Hibernate support the ability to map Account.accountNumber to Account.keys.acountId where idType='Domestic'

Regards,
Phil

_________________
PMallon


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 15, 2008 10:08 am 
Expert
Expert

Joined: Mon Nov 26, 2007 2:29 pm
Posts: 443
Try creating a subclasses of account, using idType as your "discriminator" column. Each subclass can be mapped differently.

_________________
Gonzalo Díaz


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 15, 2008 12:34 pm 
Newbie

Joined: Tue Jan 15, 2008 7:57 am
Posts: 2
Hi,
Thanks for the reply ,

Unfortunatly the Enum idType is not a closed enum.

Also I'm not clear on how this would allow existing HQL queries to run unchanged.

Basically I'd like the legacy HQL

select Account where acountNumber =:number

to be translated by Hibernate to something along the lines

select Account where keys.idType="'Domestic' and keys.accountId = :number

Ideally the legacy field accountNumber could be mapped to an expression (defined in the hibernate mapping ) which at runtimne is evaluated.

Regards
Phil

_________________
PMallon


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.