Let's say, there's a Hibernate entity configured with field access by means of annotations. I would like to map a Java class field _name
so that its logical name for Hibernate be name
, for instance, when referred from HQL queries. I need this mostly for collections.
Anticipating improper suggestions: switching access type to "property" is not possible; the task has nothing to do with the name of the physical column.
entity-name is by default the class name. This name we can use in our HQL Queries like table name in normal SQL Queries. You can give any entity name in mapping file and use it in your HQL instead of table name.
@Entity annotation marks this class as an entity. @Table annotation specifies the table name where data of this entity is to be persisted. If you don't use @Table annotation, hibernate will use the class name as the table name by default.
If no @Table is defined the default values are used: the unqualified class name of the entity. For example if you have: @Entity public class MyTest{ ... Your table will have the name my_test in your database.
In the Hibernate framework, an entity can be in three states, transient, persistent, and detached.
Based on my understanding of your question - You could define the entity like this. This will generate a hibernate table named (NewName_ABC with a column name)
@Entity
@Table(name = "NewName_ABC")
public class ABC
{
.
@Column(name = "name")
private string _name;
.
.
}
parallely can use liquibase to create the table.
Do you mean like this?
@Column(name = "name")
private string _name;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With