-->
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: Migrating to annotations
PostPosted: Tue Jul 29, 2008 7:20 pm 
Newbie

Joined: Thu Jul 24, 2008 7:25 pm
Posts: 3
I am in the process of migrating our application to annotations, from hbm.xml mapping.

My goal was to migrate without changing the code, only adding annotations.

My first problem is that our application has a root parent class that is the parent of every hibernate entity.

that class has


private Long id = null;
private Integer version;
protected StatusEnum status = StatusEnum.ACTIVE;
protected String name = null;


Id is mapped to different columns, and uses a different Generator in different entities.

I was going to use the @AttributeOverride, but I was not sure how to do this with the generator.

the other problem is that name and status (and version probably) are not mapped in all of the xml files, so it would just return the default values. This is fine in xml because the values are not referenced in the hbm files

but when I use annotations those fields are caught by reflection.

Is there a recommended way to fix either of these issues?

thanks

Kal


Top
 Profile  
 
 Post subject:
PostPosted: Sat Aug 02, 2008 5:59 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

given that you are using a class hierarchy I am assuming that all properties make sense in all subclasses (otherwise why use inheritance). So why is it wrong to map the properties for all entities. Just make sure that the objects get initialized with the right default value. Is there a problem to persist the default values?

Regarding the key generation - I guess you could implement your custom IdentifierGenerator which could act as wrapper for your different strategies. Personally I would first try to change my schema so that I for example could use the same generator. Of course that might not be possible.

--Hardy


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.