0

I have recently changed an object to have a @OneToMany mapping to another object, with the FetchType.LAZY. But when I try to load a list of these objects using a @NamedNativeQuery, which calls an Oracle function, it throws a java.sql.SQLException: Invalid column name for this new OneToMany mapping. But being marked as LAZY, it shouldn't try to populate this variable should it?

In theory I could change the function to return an empty value for this column (basically a hack), but I would have to roll that out to everywhere that uses a @NamedNativeQuery to populate one of these objects.

This seems like a bug to me. Is there a workaround, something I'm missing or possibly fixed in a later version of Hibernate?

I'm using hibernate-core 3.3.2.GA, hibernate-entitymanager 3.4.0.GA, hibernate-annotations 3.4.0.GA and hibernate-commons-annotations 3.3.0.ga.

marktucks
  • 1,771
  • 1
  • 16
  • 21
  • The error message implies it is the NAME of the column that it the problem, not its contents. Have you checked to see what the column name actually is, and whether it is invalid? You'll get more information if you enable DEBUG logging. – Stephen C Apr 16 '12 at 13:46
  • Have you used Hibernate escape char ` (backquote) to safeguard against keyword-like column names? – mazaneicha Apr 16 '12 at 13:50
  • How can you have a column for `@OneToMany` mapping in native query? `@OneToMany` doesn't involve any columns at "one" side. – axtavt Apr 16 '12 at 13:53
  • @StephenC I've tried DEBUG logging, but it's just saying invalid column. – marktucks Apr 16 '12 at 14:04
  • @mazaneicha The `JoinColumn` is SECTIONID on the "many" side, so I don't think keywords are the issue. – marktucks Apr 16 '12 at 14:08
  • @axtavt There's no column for the "one" side, but the issue is where I'm trying to populate the object on the "one" side. I think it's trying to map from the "many" side possibly. But in theory it shouldn't try to do anything for this association because it's marked as `LAZY`. – marktucks Apr 16 '12 at 14:11
  • I can not comment you question. Can you post the code of your @Entity Class and code of @NamedNativeQuery? – Alexander Apr 19 '12 at 14:19

0 Answers0