PDA

View Full Version : duplicate id - bug



Si-Coder
Sep 5th, 2009, 12:27 PM
Hi,



install jpa -provider HIBERNATE -database MYSQL
add dependency -groupId javax.annotation -artifactId jsr250-api -version 1.0

new persistent class jpa -name ~.domain.UserAccount
add field string username
add field string password
add field boolean accountNonExpired
add field boolean accountNonLocked
add field boolean creadentialsNonExpired
add field boolean enabled

new persistent class jpa -name ~.domain.UserRole
add field string name
add field string description
add field boolean enabled

new persistent class jpa -name ~.domain.Resource
add field string name
add field string description
add field boolean enabled

add field set jpa -class ~.domain.UserAccount -fieldName roles -element ~.domain.UserRole
add field set jpa -class ~.domain.UserRole -fieldName resources -element ~.domain.Resource

new controller automatic -name ~.web.UserAccountController -formBackingObject ~.domain.UserAccount
new controller automatic -name ~.web.UserRoleController -formBackingObject ~.domain.UserRole
new controller automatic -name ~.web.ResourceController -formBackingObject ~.domain.Resource

configure logging -level DEBUG -package WEB
install security

When I'm trying to add more then 2 UserRole to UserAccount then mysql throws exception about duplicating id. Is there any solution to make it work ?

Stefan Schmidt
Sep 7th, 2009, 06:10 PM
Yes this is a known issue with Hibernate. See ROO-187 (http://jira.springframework.org/browse/ROO-187) for details. In short, Hibernate applies the unique constraint to the colums in the table that connects your related entities. We are looking into workarounds, in the meantime you could try to use openJpa.

HTH,
Stefan