This content has been marked as final.
Show 1 reply
-
1. Re: Column names in embedded classes
gindhart Sep 7, 2007 4:09 AM (in response to gindhart)Hi !
I found out the answer by myself.
Maybe someone else will find the answer useful:
The default naming strategy does not regard the path thru the embedded classes to the actual entity column.
Hibernate provides an alternativ naming strategy handler which can be activated in persistence.xml using the line:<property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.DefaultComponentSafeNamingStrategy"/>
Unfortunately this out of the box naming strategy class produces some SQL grammar (mysql) errors in my case.
So I had to implement my own strategy,
activated using the line above replaced with the class name by my own strategy class.
(Sorry, I can not publish the entire class here, because I haven't got the legal rights on it)
For example the method propertyToColumnName could be implemented like this:public String propertyToColumnName(String name) { StringBuffer buf = new StringBuffer(name.length() ); String[] parts = name.split("\\."); for (int i = 0; i < parts.length; i++) { if (i > 0) { buf.append("$"); } buf.append(parts.toLowerCase()); } return buf.toString(); }