Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » (no subject)
(no subject) [message #691891] Sat, 02 July 2011 17:50
Eclipse UserFriend
Originally posted by: <forums-noreply

Hi, I'm Pal, and I keep getting a strange error. :)

I want to create custom JAAS authentication where my users and principals relationships are defined in JPA as shown:

class AuthUser

public class AuthUser implements Serializable {

// own properties
private int uid;

private String name;

// Join classes
private Set<AuthPrincipal> principals;

class AuthPrincipal

public class AuthPrincipal implements Serializable {

// Defining roles
public enum Principal {

private Principal principal;

@ManyToMany(mappedBy = "principals")
private Set<AuthUser> users;

Maps to the following Table definition

Table authprincipal
PRINCIPAL varchar(255) PK

Table authuser
UID int(11) PK
EMAIL varchar(255)
NAME varchar(255)
PASSWORD varchar(255)

Table authuser_authprincipal
users_UID int(11) PK
principals_PRINCIPAL varchar(255) PK

Now, I created a JSF file from which I call an action method that calls this one:

public void createUser(AuthUser newUser) throws UserNameExistsException, UserEmailExistsException {
AuthPrincipal role = authRoleFacade.find(AuthPrincipal.Principal.AUTHUSER);
if( role == null ){
role = new AuthPrincipal();
addPrincipalToUser(newUser, role);

The actual problem
I can create the first user. But I can't create the second user . Notice that at the second user I use the existing role object, and only cascade a merge operation, I don't know if it mattress.

The strangest thing is that it says it duplicates the 2-AUTHUSER key where 2 is the id of the new user so cannot already be in the join table. What is wrong with it or with Eclipselink or with Me?

The error what eclipselink throws

Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '2-AUTHUSER' for key 'PRIMARY'
Error Code: 1062
bind => [2 parameters bound]
Query: DataModifyQuery(name="principals" sql="INSERT INTO AUTHUSER_AUTHPRINCIPAL (principals_PRINCIPAL, users_UID) VALUES (?, ?)")
jpa many-to-many duplicates eclipselink duplicate-entry
Previous Topic:(dupliacte, ignore)
Next Topic:Programmatically obtain SQL statements emitted by EclipseLink
Goto Forum:

Current Time: Sat Apr 17 15:38:06 GMT 2021

Powered by FUDForum. Page generated in 0.02028 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top