-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: I think i've confused hibernate ... :)
PostPosted: Wed Apr 06, 2005 8:08 pm 
Newbie

Joined: Sun Dec 12, 2004 5:52 pm
Posts: 9
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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 06, 2005 8:12 pm 
Newbie

Joined: Sun Dec 12, 2004 5:52 pm
Posts: 9
Just to make things clear, when hibernate tried to map the get() method, the column name it tried to use was a zero length string ...

Yaniv


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.