Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Mapping Question

Hi

I'm trying to create two entities for a login process. Entity Users is to
contain one entry per user with the userId as the primary key, and entity
Authorities which will contain multiple roles for each user. Primary key is
the userId and authority. I'm having difficulty defining the primary key for
the authority entity. What I've got so far is listed below. When Eclipselink
tries to create the table Authorities in the database, I get - 

Internal Exception:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: BLOB/TEXT column
'USERS' used in key specification without a key length
Error Code: 1170
Call: CREATE TABLE AUTHORITIES (AUTHORITY VARCHAR(255) NOT NULL, USERS
BLOB(64000) NOT NULL, PRIMARY KEY (AUTHORITY, USERS))
Query: DataModifyQuery(sql="CREATE TABLE AUTHORITIES (AUTHORITY VARCHAR(255)
NOT NULL, USERS BLOB(64000) NOT NULL, PRIMARY KEY (AUTHORITY, USERS))")

I'd be grateful if someone could nudge me in the right direction.

Regards

@Entity
public class Users implements Serializable {

	   
	@Id
	@Column(name="username", length=50)
	private String username;
	private String password;
	private boolean enabled;
	@Version
	private int version;

... getters & setters omitted

}


@Entity
public class Authorities implements Serializable {

	
	private static final long serialVersionUID = 1L;

	@Id
	@OneToMany(mappedBy="users", targetEntity=Users.class )
	private Users users;
	
	@Id
	private String authority;

... getters and setters omitted

}
-- 
View this message in context: http://old.nabble.com/Mapping-Question-tp28374763p28374763.html
Sent from the EclipseLink - Users mailing list archive at Nabble.com.



Back to the top