I appreciate your answer. The sad story is, that sometimes release notes appear to be far from complete.
News: I finally found a solution. At least it works for my use case.
Maybe the code is useful to folks having similar problems.
// POSper is a Point of Sale System.
// Copyright (C) 2007 OXN Technologies
// Copyright (C) 2016 arcasys
// www.posper.org
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package org.posper.hibernate;
import org.hibernate.boot.model.naming.EntityNaming;
import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.naming.ImplicitJoinColumnNameSource;
import org.hibernate.boot.model.naming.ImplicitJoinTableNameSource;
import org.hibernate.boot.model.naming.ImplicitNamingStrategyLegacyJpaImpl;
/**
* @author Hans <
[email protected]>
*
*/
public class PosperNamingStrategy extends ImplicitNamingStrategyLegacyJpaImpl {
private static final long serialVersionUID = -6156051787915506283L;
private static final String PREFIX = "posper_";
@Override
protected String transformEntityName(EntityNaming entityNaming) {
return PREFIX + entityNaming.getJpaEntityName().toLowerCase();
}
@Override
public Identifier determineJoinTableName(ImplicitJoinTableNameSource source) {
String tname = (PREFIX +
source.getOwningEntityNaming().getJpaEntityName() + "_" +
source.getNonOwningEntityNaming().getJpaEntityName()).toLowerCase();
System.out.println("0: " + tname);
return Identifier.toIdentifier(tname);
}
@Override
public Identifier determineJoinColumnName(ImplicitJoinColumnNameSource source) {
final String name;
if ( source.getNature() == ImplicitJoinColumnNameSource.Nature.ELEMENT_COLLECTION
|| source.getAttributePath() == null ) {
// This is the relevant change to avoid that the join column name is also prefixed
// which happened for ManyToMany associations
name = source.getEntityNaming().getJpaEntityName().toLowerCase()
+ '_'
+ source.getReferencedColumnName().getText();
}
else {
name = transformAttributePath( source.getAttributePath() )
+ '_'
+ source.getReferencedColumnName().getText();
}
return toIdentifier( name, source.getBuildingContext() );
}
}