-->
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: Changing default property name with annotations
PostPosted: Mon Jan 08, 2007 8:47 am 
Senior
Senior

Joined: Sun Jan 04, 2004 2:46 pm
Posts: 147
Hibernate version: 3.2.1
Hibernate annotation version: 3.2.0

Hi there,

I have recently upgraded from hibernate 2.1.7 to 3.2.1. The migration was very smooth except for one problem which I suspect is of my own making but I can't find a way round it.

Previously I used .hbm.xml files. An example property looked like this

Code:
    <property name="ActId" column="act_id" type="int" not-null="true" />


Note the ActId starts with an uppercase letter.

Converting to Hibernate 3 and using annotations now the property name has changed to actId.

Here's the annotation used.

Code:
    @javax.persistence.Basic
    @javax.persistence.Column( name = "act_id", nullable = false )
    @org.hibernate.annotations.Type( type = "int" )
    public int getActId() { return this.ActId; }
    public void setActId(int val) {this.ActId = val; }


This of course means all my queries that use a property name are failing because the case has changed.

I couldn't find anyway using annotations to override the property name so it matches what I had before. I've poked through all the javax.persistence and org.hibernate.annotations packages but to no avail.

Is this possible or will I have to fallback to the xml files or change all my HQL queries?

Regards,
Mike

P.S. I know the ActId property is probably wrong but after 3 years of accumulated HQL queries I'm kinda stuck with it.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 08, 2007 1:38 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
I woudl change the HQL queries, but an hbm file will work

_________________
Emmanuel


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.