I'm stuck

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

I'm stuck

Jonathan Carlson
I get this error: org.hibernate.MappingException: collection foreign key
mapping has wrong
number of columns: Message.replies type: long

When I remove the replies and relatesToMany properties from Message the
error goes away.  Any idea for what I could try would be very much
appreciated.  I had a one-to-many self relationship working before, but
I can't see how this one is different.

Thanks!

Jonathan

======================================
class Forum {
  @Property Long id
  @Property Long version
 
  @Property relatesToMany = [initialMessages : Message]
 
  @Property String name = ""
  @Property Set initialMessages = new HashSet()
 
  def startThread(Message msg) {
    msg.forum = this
    initialMessages.add(msg)
  }
 
  public String toString() { return "Forum:" + name }  
}
======================================
class Message {
  @Property Long id
  @Property Long version

  @Property relatesToMany = [replies : Message]

  /** replyTo will be null for first message in thread only */
  @Property Message replyTo = null
  @Property Set replies = new HashSet()
  /** forum is non-null only for the first message in a thread */
  @Property Forum forum = null
  @Property String subject = ""
  @Property String userName = ""
  @Property Date date = new Date()
  @Property String body = ""
 
  @Property constraints = {
    userName(blank:false, length:1..30)
    date()
    body(widget:'textarea', length:0..2000)
  }
 
  def addReply(Message msg)
  {
    msg.replyTo = this
    replies.add(msg)
  }
 
  public String toString() { return "Message:${userName}:${body}" }

}

______________________________________________________________________
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

Katun Corporation -- www.katun.com
_____________________________________________________________________

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

______________________________________________________________________
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

Katun Corporation -- www.katun.com
_____________________________________________________________________
Reply | Threaded
Open this post in threaded view
|

Re: I'm stuck

graemer
Hi Jonathan,

This problem should be fixed in CVS head or by downloading the latest
0.2 snapshot

Cheers
Graeme

On 3/29/06, Jonathan Carlson <[hidden email]> wrote:

> I get this error: org.hibernate.MappingException: collection foreign key
> mapping has wrong
> number of columns: Message.replies type: long
>
> When I remove the replies and relatesToMany properties from Message the
> error goes away.  Any idea for what I could try would be very much
> appreciated.  I had a one-to-many self relationship working before, but
> I can't see how this one is different.
>
> Thanks!
>
> Jonathan
>
> ======================================
> class Forum {
>   @Property Long id
>   @Property Long version
>
>   @Property relatesToMany = [initialMessages : Message]
>
>   @Property String name = ""
>   @Property Set initialMessages = new HashSet()
>
>   def startThread(Message msg) {
>     msg.forum = this
>     initialMessages.add(msg)
>   }
>
>   public String toString() { return "Forum:" + name }
> }
> ======================================
> class Message {
>   @Property Long id
>   @Property Long version
>
>   @Property relatesToMany = [replies : Message]
>
>   /** replyTo will be null for first message in thread only */
>   @Property Message replyTo = null
>   @Property Set replies = new HashSet()
>   /** forum is non-null only for the first message in a thread */
>   @Property Forum forum = null
>   @Property String subject = ""
>   @Property String userName = ""
>   @Property Date date = new Date()
>   @Property String body = ""
>
>   @Property constraints = {
>     userName(blank:false, length:1..30)
>     date()
>     body(widget:'textarea', length:0..2000)
>   }
>
>   def addReply(Message msg)
>   {
>     msg.replyTo = this
>     replies.add(msg)
>   }
>
>   public String toString() { return "Message:${userName}:${body}" }
>
> }
>
> ______________________________________________________________________
> This email and any files transmitted with it are confidential and
> intended solely for the use of the individual or entity to whom they
> are addressed. If you have received this email in error please notify
> the system manager.
>
> Katun Corporation -- www.katun.com
> _____________________________________________________________________
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email
> ______________________________________________________________________
>
> ______________________________________________________________________
> This email and any files transmitted with it are confidential and
> intended solely for the use of the individual or entity to whom they
> are addressed. If you have received this email in error please notify
> the system manager.
>
> Katun Corporation -- www.katun.com
> _____________________________________________________________________
>