Re: Complex Hibernate mapping (or not?)
- From: JScoobyCed <pim@xxxxxxxx>
- Date: Mon, 22 May 2006 09:14:24 +0700
Snyke wrote:
Once again I'm running against a solid wall of errors, and my head
starts to hurt really badly with this one :-)
I have a bidirectional link between two classes
Account <=> User
this being a many-to-many relationship. Until now nothing fancy, but I
have a Class inbetween that manages accessrights called Privilge, this
just has two boolean values (read and write) that tell wether a user
can read or write to the account.
Account <-many-to-one-> Privilege <-one-to-many-> User
basically every Account-User combination has a Privilege.
Hi. I followed this Thread and triied to give it a check.
I downloaded your code and ran it. I need to create a class BaseVO.java as you didn't provide it. Here is what I put:
<BaseVO.java>
public class BaseVO {
private int id = -1;
private Privilege[] userPrivileges = null;
public int getId() {
return id;
}
public void setId(int i) {
id = i;
}
public Privilege[] getUserPrivileges() {
return userPrivileges;
}
public void setUserPrivileges(Privilege[] priv) {
userPrivileges = priv;
}
}
</BaseVO.java>
I am not sure the set/get on userPrivileges are in this class or not. But Hibernate was complaining there was no setter/getter for userPrivileges in UserAccount. I thought ot put it in BaseVo as it was not in your original UserAccount.java
Anyway, after creating the DB in mysql, the only output I have is:
classic factory
I don't have any error message. So I guess you might have a different DB than me. Here is my DB script:
<db_mysql>
CREATE TABLE accounts (
id int(11) NOT NULL,
`name` varchar(32) NOT NULL
);
CREATE TABLE privilege (
id int(11) NOT NULL auto_increment,
isread tinyint(4) NOT NULL,
iswrite tinyint(4) NOT NULL,
`user` int(11) NOT NULL,
account int(11) NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE users (
id int(11) NOT NULL auto_increment,
`name` varchar(32) NOT NULL,
`password` varchar(32) NOT NULL,
user_privileges int(11) NOT NULL,
PRIMARY KEY (id)
);
</db_mysql>
Note that MySQl (and many DBMS) have 'user', 'password' and 'name' reserved (so MySQl encloses them with backquotes). Maybe that's what is perturbing Hibernate. I am using hibernate 3.
--
JSC
.
- Follow-Ups:
- Re: Complex Hibernate mapping (or not?)
- From: Snyke
- Re: Complex Hibernate mapping (or not?)
- References:
- Complex Hibernate mapping (or not?)
- From: Snyke
- Complex Hibernate mapping (or not?)
- Prev by Date: Re: Something like Visual Assist for Eclipse
- Next by Date: Re: convert byte[] to actual string value
- Previous by thread: Re: Complex Hibernate mapping (or not?)
- Next by thread: Re: Complex Hibernate mapping (or not?)
- Index(es):
Relevant Pages
|
Loading