[jboss-user] [EJB 3.0] - Re: Column names in embedded classes

gindhart do-not-reply at jboss.com
Fri Sep 7 04:09:50 EDT 2007


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();
  | }
  | 



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4081966#4081966

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4081966



More information about the jboss-user mailing list