Hello,
We are trying to move from our "in house" orm to JPA. For some attributes, we need to define hibernate UserType.
The problem is that we would like to keep hibernate-core as an optional dependency in our legacy framework and at the same time being able to use hibernate UserType (i.e. using @Type, @TypeDefs).
For instance, the following class "AuditSegment" is an embeddable entity that uses the UserType "MyUserType". Unfortunately, this class is annotated by the annotations "TypeDefs", "TypeDef" and "Type" contained in hibernate-core and so it is no more an optional feature in the classpath.
Code:
@TypeDefs({
@TypeDef(name = " MyUserType ", typeClass = MyUserType.class)
})
@Embeddable
public class AuditSegment {
@Type(type = " MyUserType")
ComplexObject aComplexObject;
}
Is there a way to avoid that situation? For instance, we can declare user types at the package level in package-info.java in an optional JAR, but can we do something similar with the "@Type" annotation?
We took a look at to the only alternative we have found: XML mapping files. With XML files, the type definition looks like:
Code:
<typedef name=" MyUserType "
class="com.xyz.jpa.support.mapper.MyUserType "></typedef>
The type annotation can be declared in XML like that:
Code:
<property name=" aComplexObject" type=" MyUserType "/>
But, it seems that if we start using hbm files in some classes, we have to use hbm mapping files for the whole class hierarchy and we would like to promote usage of annotations.
Any suggestions/solutions are welcome ?
Thanks :)
S.