Too many tables, MySQL
caye Mar 17, 2008 1:45 PMHi,
I have been facing this problem quite many times with one of my projects, the fact is that i couldnt solve it 100%. It happens when i try to load an entity that is a list of entities.
For example, these are my basic entities in tis problem.
@Entity
@Table(name="userproperties")
@Scope(SESSION)
public class UserProperty {
@Id @GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String name;
private String info;
private boolean critical;
private boolean deadline;
private String path;
private Allowance allowance;
@OneToOne
private Userdata userdata;
@OneToOne
private UserdataExtended userdataExtended;
*@ManyToOne
private UserPropertyList propertyList;*
@Lob @Basic(fetch = FetchType.LAZY)
@Column(length = 15000000)
private byte[] data = null;
@Temporal(TemporalType.TIMESTAMP)
private Date issuance;
@Temporal(TemporalType.TIMESTAMP)
private Date expire;
public UserProperty() {}
public UserProperty(String name,boolean critical) {
this.name = name;
this.critical = critical;
deadline = false;
}
public UserProperty(String name,boolean critical,boolean deadline) {
this.name = name;
this.critical = critical;
this.deadline = deadline;
}
getters and setters....And then the list of properties.
@Entity
@Table(name="userpropertiesList")
@Scope(SESSION)
public class UserPropertyList {
@Id @GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String name;
private String info;
private boolean critical;
private boolean stored;
private boolean deadline;
private Allowance allowance;
@OneToOne
private Userdata userdata;
@OneToOne
private UserdataExtended userdataExtended;
*@OneToMany(mappedBy="propertyList")
private Collection<UserProperty> properties = new HashSet();*
public UserPropertyList() {}
public UserPropertyList(String name,boolean critical) {
this.name = name;
this.critical = critical;
this.stored = false;
this.deadline = false;
}
public UserPropertyList(String name,boolean critical,boolean deadline) {
this.name = name;
this.critical = critical;
this.stored = false;
this.deadline = deadline;
}
getters and setters....So basically i have a userProperty and a userPropertyList that have the name of the list, the critical, allowance...etc and the list of properties. When i tried to load this is when it complains about too many tables in a join... My question is... there is some way to make the ManyToOne without try to load all the related class to the properties???
I would like really to know this, because obviously i am doing something wrong in the whole structure.
Thanks in advance!