-->
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: Null Components
PostPosted: Wed Aug 18, 2004 1:38 pm 
Beginner
Beginner

Joined: Mon Nov 24, 2003 5:39 am
Posts: 26
Location: France
Quote:
Like all value types, components do not support shared references. The null value semantics of a component are ad hoc. When reloading the containing object, Hibernate will assume that if all component columns are null, then the entire component is null. This should be okay for most purposes.


This is not okay when I try to populate my mapped object, which contains a component with columns that are null, from the front-end with e.g. <spring:bind/> tags. The BeanWrapper underneath throws an exception because the underlying components has not been initialized.

Code:
BeanWrapper wrapper = new BeanWrapperImpl(form);
wrapper.setPropertyValue("p1.nom","Joe Tester");
      assertEquals("Joe Tester",form.getP1().getNom());

fails

Is instantiating the components within the mapped class's private fields the recommended way to avoid this problem? Like this:

Code:
public class Form
{
private P p1 = new P();
private P p2 = new P();
private P p3 = new P();

/**
     * @hibernate.component
     * prefix="P1_"
     */
    public final P getP1()
    {
        return p1;
    }
    public final void setP1(P p1)
    {
        this.p1 = p1;
    }

...

Any other solutions?


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.