When executing a Criteria Query in hibernate, I get the following exception:
javax.persistence.PersistenceException: javax.persistence.PersistenceException: org.
I had the same problem. It was due to an enum in a @SqlResultSetMapping
. The solution is here: @ConstructorResult with Enum in JPA 2.1
Edit, due to a comment from @Eugene Mihaylin:
So, I had the following situation:
@SqlResultSetMapping(
name = "MyTargetClassMappingName",
classes = {
@ConstructorResult(
targetClass = MyTargetClassDTO.class,
columns = {
@ColumnResult(name = "name_from_query1"),
@ColumnResult(name = "name_from_query2"),
...
@ColumnResult(name = "name_of_problematic_column", type = MyCustomEnum.class),
}
)
})
@Entity
public class MyTargetClassDTO ...
And I needed to change to:
@SqlResultSetMapping(
name = "MyTargetClassMappingName",
classes = {
@ConstructorResult(
targetClass = MyTargetClassDTO.class,
columns = {
@ColumnResult(name = "name_from_query1"),
@ColumnResult(name = "name_from_query2"),
...
@ColumnResult(name = "name_of_problematic_column", type = String.class),
}
)
})
@Entity
public class MyTargetClassDTO ...
in order to fix the issue.
Later, in the constructor of the DTO (annotated as @Entity
), I am doing: MyCustomEnum.valueOf(...)
in order to parse the value of the string and assign it to the specified field of type MyCustomEnum
in the DTO.