Search code examples
hibernatejpa

Hibernate changes @Table(name) to lowercase


I have a Table Per Class Inheritance in Hibernate.

@Entity
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
public abstract class A {
}

@Entity
@Table(name="B")
public class B extends A {
}

@Entity
@Table(name="C")
public class C extends A {
}

I'm just trying to validate the schema. I have already B and C tables in db.

I'm using <property name="hibernate.ejb.naming_strategy" value="org.hibernate.cfg.ImprovedNamingStrategy"/> but I think that specifying @Table(name) override the behavior of naming strategy!

Why does Hibernate convert the name specified in @Table to lowerCase and searching for b and c instead of B and C? How can I avoid this?


Solution

  • If you are using JPA 2.0, the spec says:

    It is possible to specify that all database identifiers in use for a persistence unit be treated as delimited identifiers by specifying the <delimited-identifiers/> element within the persistence-unit-defaults element of the object/relational xml mapping file. If the <delimited-identifiers/> element is specified, it cannot be overridden.

    This setting should cause Hibernate to use the uppercase names of your tables, since that is how you have specified the names in your annotations.