• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate: @OneToMany Problem when initialising collection

 
Carlos Conti
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,

I have a really weird issue arising:
By watching at the following code pieces, the relationships build between these classes, Incidencia, ImputacionDocumentoImputable and DocumentoImputable should be right isn't it?


Class Incidencia




Class ImputacionDocumentoImputable



Class DocumentoImputable



The problem arises when Incidencia's metod "getGastoAcumulado()" is called, and accessing the List member 'imputacionDocumentoImputable'. I get an exception like:



The most curious thing is that it used to work, and after a while (and some changes in the application) it is not working properly anymore. The mapping between Incidencia->ImputacionDocumentoImputable<-DocumentoImputable should be fine isn't it? I have such mapping type, and done the same way overall my application and seems to work. The only thing I can figure out might be making the persistence environment to complain is that DocumentoImputable is a base class for some others.

Does anyone happen to know what I am missing?
I am starting to get desperate... can't find a solution.


Thanks in advance,

Carlos.
 
Carlos Conti
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Found it!, hope nobody missed a second on this!

was a bit reluctant to check the sql thrown by hibernate, but it was the key

one of the tables somehow didn't have the id field. One of the inherited classes were MovtoAlmacen ( another descendant of DocumentoImputable ).

I figured out logging the thrown sql, and running it directly in the database, found the table for the specified table alias (left outer joins) and saw that it was complaining about the "id" field for that table. When I checked, I saw it didn't have an id field.
Added it and it worked.

Regards,
Carlos.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic