views:

21

answers:

1

Hi all,

I have a problem with how hibernate/JavaBeans constructs property names.

Here's my property.

private boolean aNumberFl;

@Column( name = "aNumberFl", nullable = false )
@Type( type = "yes_no" )
public boolean getANumberFl()
{
    return aNumberFl;
}

public void setANumberFl( boolean var )
{
    this.aNumberFl = var;
}

Everything is fine except for fact the hibernate internally thinks my property names is ANumberFl rather than aNumberFl. The JavaBean conventions checks the first two chars of the property getter (after the get) and if they are both capitals and does not uncapatilise to get the property name. However this is inconsistent with my field name which has a lower case. This is all permissible in JavaBean world but having a field called aNumberFl OR ANumberFl would yield the same getter name. This means when the get method is the source it has to pick one of the other, and is picking the latter.

I tried moving the annotations onto the field but that caused other issues which I won't go into now, and am not sure that's a good idea anyway.

Is there anyway of overriding the default property name that hibernate infers from the getter method name?

Thanks.

+1  A: 

I'll advice to rename the property and give it a more meaningful name

  • remove the a - if it is "A-Number", and you have a "B-Number", make the property uppercase - ugly, but might work.
  • Fl doesn't mean anything - expand that abbreviation and all will be fine.
Bozho