Reputation: 41
I am new in java Hibernate and i try to make simple Hello world
project.
I make a UserClass:
@Entity
@Table(name = "Table_User")
public class Table_User extends BaseObject implements Serializable {
private String name;
public Table_User(){
//default constructor
}
public TableUser(String name){
this.name=name;
}
public String getName(){ return this.name; }
public void setName(String name){ this.name=name; }
}
I am generate table using <property name="hibernate.hbm2ddl.auto" value="update"/>
.
My question is.
How can i SET encoding for table and row name
?
I want set utf8_czech_ci
but is latin1_swedish_ci
.
Thank you for your reply!
EDIT, my persisence.xml
file is:
<persistence-unit name="org.my" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<properties>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="openjpa.jdbc.SynchronizeMappings" value="buildSchema"/>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.connection.password" value=""/>
<property name="hibernate.connection.username" value="root"/>
<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/myDb"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
<property name="hibernate.validator.apply_to_ddl" value="true" />
<property name="connection.provider_class" value="org.hibernate.connection.C3P0ConnectionProvider"/>
<property name="hibernate.c3p0.min_size" value="5"/>
<property name="hibernate.c3p0.max_size" value="20"/>
<property name="hibernate.c3p0.timeout" value="300"/>
<property name="hibernate.c3p0.max_statements" value="50"/>
<property name="hibernate.c3p0.idle_test_period" value="300"/>
</properties>
</persistence-unit>
</persistence>
Upvotes: 2
Views: 591
Reputation: 153810
The encoding is always set at database level, not in the Hibernate mapping. If you are using MySQL, you can set it as follows:
CREATE DATABASE mydb
DEFAULT CHARACTER SET utf8
DEFAULT COLLATE utf8_czech_ci;
Upvotes: 1