Tag: hibernate

ORA-00957: duplicate column name with Hibernate

This error was particularly annoying, because it didn’t appear on my local machine, but only on the remote environment. Environments were exactly the same: Apache versions, Oracle driver versions,  the same DB is used. Everything else is same, because builds are managed by IVY. 

Looking at SQL that was generated, Hibernate was generating duplicate column names when an entity with several JOINED entities was being retrieved. I couldn’t set alias for related entities because I am using Criteria API and all relationships are configured by annotations.

I am still not sure what is the problem. The way I solved it is by making all related entities load LAZILY. Please let me know if someone finds an answer to this.

Hibernate with DB Visual Architect tool from VisualParadigm

Important things to note:

1. If you want to see “relationship” fields in generated classes -> in ERD (Entity Relationship Diagram) -> right click on the property -> open specifications -> generated: always
2. Note that it will also require property to be set as NULLABLE and have a default value (i use NULL)
1. If working with NetBeans check that error is not actually happening somewhere in the code. Especially if it says something like:
ERROR JDBCExceptionReporter:101 – Unknown column ‘ParentId’ in ‘where clause’
In addition, compiler will not show you the exact position in the code.
I was so frustrated, I actually started doing manual Hibernate code… till I decided to give it a final try!