Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
3.2
Mapping documents:
...
<component name="SomeList" class="org.example.SomeList">
<array name="SomeId" table="SomeTable">
<key column="ParentId" not-null="true" />
<list-index column="ArrayIndex" />
<element type="org.example.SomeIdType"
column="SomeId" not-null="true" unique="true" />
</array>
</component>
...
Name and version of the database you are using:
MySQL 5
Relevant Java code:
protected void validateSomeId(org.example.SomeId[] param){
if ((param != null) && (param.length < 1)){
throw new java.lang.RuntimeException();
}
}
public void setSomeId(org.example.SomeId[] param){
validateSomeId(param);
this.localSomeId=param;
}
Can someone help me create the proper mapping file to prevent Hibernate from initializing an empty array and adding it to my class?
I am trying to use Hibernate with Axis2 and one of the restrictions in my web service schema is that there needs to be one or more SomeId elements in the request. I used WSDL2Java to create my code and it added the validate method to make sure this restriction is met. However, when initializing the SomeList class, Hibernate tries to populate it with an empty wrapper and an exception is thrown.
Why does Hibernate initialize two arrays, one empty and one with the values from my database? Can't it just tell there is valid data and skip the first step?
Thanks for your help!
Yours,
Jason
P.S. I tried to use the access=”field” method instead, but it turns out Hibernate is first passing in the good array, but then it overwrites it with the empty one!