I'm trying to force JPA/Hibernate to generate and use only lowercase tablenames. I've implemented a NamingStrategy like this:
public class MyNamingStrategy extends DefaultNamingStrategy {
@Override
public String classToTableName(String className) {
return super.classToTableName(className).toLowerCase();
}
}
I have applied it by setting this property in persistence.xml:
<property name="hibernate.ejb.naming_strategy" value="entities.strategy.MyNamingStrategy"/>
When I do this I get this stacktrace:
SEVERE: Exception while invoking class org.glassfish.persistence.jpa.JPADeployer prepare method
org.hibernate.DuplicateMappingException: Same physical table name [planning] references several logical table names: [Planning], [OrderProductMan_Planning]
at org.hibernate.cfg.Configuration$MappingsImpl.addTableBinding(Configuration.java:2629)
at org.hibernate.cfg.annotations.TableBinder.buildAndFillTable(TableBinder.java:254)
at org.hibernate.cfg.annotations.TableBinder.bind(TableBinder.java:177)
What does the
Same physical table name [planning] references several logical table names: [Planning], [OrderProductMan_Planning]
mean?
Entities from the error, simplified as much as I could. Let me know if you need the rest.
@Entity
public class Planning implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
private Integer qty;
@ManyToOne
private OrderProductMan orderProduct;
....
}
@Entity
@Table
public class OrderProductMan implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
private Integer opId;
@Basic(optional = false)
private int qty;
@ManyToOne(optional = false)
private ProductMan produse;
@ManyToOne(optional = false)
private OrderMan orders;
@Transient
private int totalScheduled;
@Transient
private int totalProduced;
// ...
}