Hi all,
I think i ran into a bug but i'm not sure .... :)
I'm using hibernate 3 annotations + mysql to map a container class.
The container class looks something like this:
Code:
@Entity
public class ContainerClass {
Set<ContainerClass> children = new HashSet<ContainerClass>();
private ContainerClass parent;
private long id;
@Id
@Column(name = "ID")
public long getId() { return id; }
public void setId(long id) { this.id = id; }
public ContainerClass get(long id) {
//search for id
//return result;
}
public void add(ContainerClass child) {
//add child to collection
//set parent of child
}
public void remove(long id) {
//remove child from collection
//remove parent of child
}
@ManyToOne
@JoinColumn(name = "PARENT_ID")
public ContainerClass getParent() { return parent; }
public void setParent(ContainerClass parent) {
this.parent = parent;
}
@OneToMany
@JoinColumn(name = "ID")
private Set<ContainerClass> getChildren() {
return children;
}
private void setChildren(Set<ContainerClass> children) {
this.children = children;
}
}
now, while attempting to get a sessionfactory, i kept getting an exception, here is the trace:
Code:
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 0
at java.lang.String.charAt(String.java:558)
at org.hibernate.mapping.Column.setName(Column.java:56)
at org.hibernate.cfg.Ejb3Column.<init>(Ejb3Column.java:41)
at org.hibernate.cfg.Ejb3Column.buildColumnFromAnnotation(Ejb3Column.java:160)
at org.hibernate.cfg.AnnotationBinder.processElementAnnotations(AnnotationBinder.java:649)
at org.hibernate.cfg.AnnotationBinder.processElementsOfAClass(AnnotationBinder.java:532)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:382)
at org.hibernate.cfg.AnnotationConfiguration.addAnnotatedClass(AnnotationConfiguration.java:44)
at org.hibernate.cfg.AnnotationConfiguration.parseMappingElement(AnnotationConfiguration.java:182)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1353)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1335)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1302)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1230)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1216)
after digging in the hibernate code abit, i found out that it tried to map the collection's get() method.
can anyone tell me what they make of it, is it a bug, or my own stupidity and there is some annotation i should put before the get() method (except for @Transient) ?
Thanks,
Yaniv