Hibernate UserType problem
I am trying my hands on H开发者_StackOverflow社区ibernate's userType and struck in some problem.here is my mapping file
<hibernate-mapping>
<class name="MyClass"
table="MYTABLE">
<id name="uuid" type="java.lang.String">
<column name="UUID" />
<generator class="uuid" />
</id>
<property name="myClass_UserType" type="MyClassUserType" >
<column name="A"/>
<column name="B"/>
<column name="C"/>
</property>
</class>
</hibernate-mapping>
and here is the code from my CompositeUserType
@Override
public void nullSafeSet(PreparedStatement ps, Object arg1, int index,
SessionImplementor arg3) throws HibernateException, SQLException {
if(arg1==null){
//todo
}
else{
MyClass_UserType mc=(MyClass_UserType)arg1;
mc=dao.save(mc);
ps.setString(index, mc.getXYZ());
ps.setString(index+1, mc.getXYZ());
ps.setString(index+2, mc.getXYZ());
ps.setString(index+3, mc.getXYZ());
}
}
i want to get access to MyClass instance inside the nullSafeSet(...) method. i have access to MyClass_UserType in this method but some how not able to get instance of the MyClass.
Is there any way to get reference/access of this MyClass instance
Thanks in advance
Is u define the MyClass in your working package, as mapping file says that u are mapped a tabel MYTABLE with MyClass but really define it, if it is then i am sure that the instance of MyClass is access in inside any class within the same package or somewhere else through import so plz chek it your MyClass.
精彩评论