PDA

View Full Version : BeanModelMarker POJO inheritance



calicoder
25 May 2009, 11:48 PM
I have a base class called Identifiable. The Identifiable class has two private fields (Long id, Integer version). Each of my
POJOs extends the Identifiable base class to adhere to Hibernate.

My problem is that when I write a BeanModelMarker like this where MyPojo extends Identifiable:


@BEAN(MyPojo.class)
public interface MyPojoBeanModel extends BeanModelMarker {

}

the 'id' and 'version' fields are always null.

Any clues?

rian.k
25 May 2009, 11:56 PM
Haven't tried BeanModels in grids, but I noticed the mapping of field names was inconsistent when I tried to reference them via a XTemplate. E.g. I had two fields in two Beans:

private String sPropertyName;

private String sFunctionName;while their `stringified' version in the Models ended up to be:

get("propertyname");

get("functionName");

calicoder
26 May 2009, 12:30 AM
I haven't noticed that when using it with grids. I think that this behavior, the behavior that I'm describing is intentional since the object graph could get crazy big if not careful. I wonder if there is a way to override that behavior and bring up inherited fields as well as defined fields?

sdc
26 May 2009, 6:25 AM
Does your Identifiable class have getters and setters for these 2 attributes ?

calicoder
26 May 2009, 9:21 PM
yes, both public

brendand
28 May 2009, 5:50 PM
yes, both public

what are the names of the getters and setters?

I'm guessing you have getPropertyname, setPropertyname, getFunctionName, setFunctionName.

calicoder
28 May 2009, 7:45 PM
getId, setId
getVersion, setVersion

...naturally

rian.k
28 May 2009, 9:15 PM
what are the names of the getters and setters?

I'm guessing you have getPropertyname, setPropertyname, getFunctionName, setFunctionName.

Uh thanks, that solved my problem! I'm digging a hole now.. :">