Hello, I using such field mapping for Testing user - user_groups relation
@ElementCollection
@CollectionTable(name = "USERS_GROUP", joinColumns = {@JoinColumn(name = "USER_NAME", referencedColumnName = "LOGIN")})
@Enumerated(EnumType.ORDINAL)
@Column(name = "USER_GROUP")
private Set<UserRole> groups = new HashSet<UserRole>();
But when I execute JPQL query "SELECT user FROM User user WHERE user.name = :name AND :group MEMBER OF user.groups" I got incompatible data type in conversion exception.
Log4j show next trace:
Hibernate: select user0_.id as id11_, user0_.locked as locked11_, user0_.login as login11_, user0_.name as name11_, user0_.password as password11_ from users user0_ where 1=1 and user0_.name=? and (? in (select groups1_.USER_GROUP from USERS_GROUP groups1_ where user0_.login=groups1_.USER_NAME))
2012-11-23 11:38:12,491 TRACE [org.hibernate.type.descriptor.sql.BasicBinder] – <binding parameter [1] as [VARCHAR] - name3>
2012-11-23 11:38:12,491 TRACE [org.hibernate.type.descriptor.sql.BasicBinder] – <binding parameter [2] as [VARBINARY] - OPERATOR>
2012-11-23 11:38:12,491 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] – <SQL Error: -5561, SQLState: 42561>
2012-11-23 11:38:12,491 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] – <incompatible data type in conversion>
As we can see group param have type VARBINARY, but in database it is integer.
|