-->
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.  [ 4 posts ] 
Author Message
 Post subject: Use of non Java-Bean standard names for persistent Fields
PostPosted: Wed May 05, 2004 3:47 pm 
Regular
Regular

Joined: Wed May 05, 2004 3:41 pm
Posts: 118
Location: New Jersey,USA
Say I have a class as below:

public class Name{

private Long _lPKId
private String _strFirstName;
private String _strLastName;
//getters and setters
}

I have a hibernate mapping as below:

<class name="Name" table ="employee_name">
<id column="seq_id" name="_lPKId" type="long">
<generator class="sequence">
<param name="sequence">seq_name</param>
</generator>
</id>
<property name="_strFirstName" column="first_name"/>
<property name="_strLastName" column="last_name"/>
</class>

Will this work to persist my object into the DB. I tried a similar example and the following exception was thrown:-

Caused by: java.lang.RuntimeException: Exception building SessionFactory: Could not find a setter for property _lPKId in class Name

How do I have my own naming convention and be able to use Hibernate or am I forced to change my naming conventions for fields.

Thanks,

anand


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 05, 2004 4:06 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
I'd suggest implementing a custom PropertyAccessor or try access=field


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 05, 2004 4:26 pm 
Regular
Regular

Joined: Wed May 05, 2004 3:41 pm
Posts: 118
Location: New Jersey,USA
Michael,

"access=field" did the trick. Are there any downsides to using this setting other than it being non-JavaBean conventions.

Thanks,

Anand


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 05, 2004 8:57 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Since the fields are marked as private, more restrictive security managers will most likely throw IllegalAccessExceptions. But if you have control over the security manager config you should be ok


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.