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.  [ 1 post ] 
Author Message
 Post subject: Can hibernate access a component's parent by field?
PostPosted: Fri Apr 09, 2010 6:42 am 
Newbie

Joined: Fri Apr 09, 2010 12:35 am
Posts: 1
Hi all,

In the mapping file, if my entity bean defines a component with a <parent> tag to wire up a backward reference, is there a way to specify the access type of that reference to be "field" rather than "property"? For example,

mapping:
Code:
<class name="Cat" table="cat">
    ...
    (some properties)
    ...
    <component name="assistant" class="AssistantCat" access="field">
        <parent name="boss" />
        ...
        (some properties)
        ...
    </component>
</class>


entity classes:
Code:
public class Cat{
    private Assistantcat assistant;
    ...
    (other fields)
    ...
   
    private Cat(){}
    ...
}

public class AssistantCat{
    private Cat boss;
    ...
    (other fields)
    ...

    private AssistantCat(){}
    ...
}


In this case I have to add a setter for boss to make the mapping work. Is there any way to avoid this?
In addition, if I set the default access type as field like the following, hibernate still tries to access "boss" by property.

Code:
<hibernate-mapping default-access="field">
    ...
</hibernate-mapping>


Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.