Using
Hibernate 4.0.0.Beta1 (while migrating to JBoss 7.0.0.Final) I get the following error while deploying when using the schema validator from hibernate (DB is Oracle Database 10g Enterprise Edition Release 10.2.0.1.0):
Code:
14:30:14,800 INFO [org.hibernate.tool.hbm2ddl.TableMetadata] (MSC service thread 1-2) HHH00037:Columns: [emp_year_of_birth, emp_password, emp_extern, emp_id, emp_firstname, emp_location, emp_override_grp, emp_lastname, emp_login, emp_group_id, emp_experience_since, emp_email]
14:30:14,815 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-2) MSC00001: Failed to start service jboss.persistenceunit."MyApp.ear/myapp-server-2.3.7-SNAPSHOT.jar#MyAppPersistence": org.jboss.msc.service.StartException in service jboss.persistenceunit."MyApp.ear/myapp-server-2.3.7-SNAPSHOT.jar#MyAppPersistence": Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1786)
at org.jboss.msc.service.ServiceControllerImpl$ClearTCCLTask.run(ServiceControllerImpl.java:2291)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) [:1.6.0_26]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) [:1.6.0_26]
at java.lang.Thread.run(Thread.java:662) [:1.6.0_26]
Caused by: javax.persistence.PersistenceException: [PersistenceUnit: MyAppPersistence] Unable to build EntityManagerFactory
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:903)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:879)
at org.hibernate.ejb.HibernatePersistence.createContainerEntityManagerFactory(HibernatePersistence.java:73)
at org.jboss.as.jpa.service.PersistenceUnitService.createContainerEntityManagerFactory(PersistenceUnitService.java:170)
at org.jboss.as.jpa.service.PersistenceUnitService.start(PersistenceUnitService.java:80)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1765)
... 4 more
Caused by: org.hibernate.HibernateException: Wrong column type in MYSCHEMA.EMPLOYEE for column EMP_EXTERN. Found: number, expected: boolean
at org.hibernate.mapping.Table.validateColumns(Table.java:281)
at org.hibernate.cfg.Configuration.validateSchema(Configuration.java:1264)
at org.hibernate.tool.hbm2ddl.SchemaValidator.validate(SchemaValidator.java:155)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:449)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1720)
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:77)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:894)
... 9 more
Here the simplified DDL of the table
EMPLOYEE:
Code:
CREATE TABLE "MYSCHEMA"."EMPLOYEE"
(
"EMP_ID" NUMBER(10,0) NOT NULL ENABLE,
"EMP_FIRSTNAME" VARCHAR2(100 BYTE) NOT NULL ENABLE,
"EMP_LASTNAME" VARCHAR2(100 BYTE) NOT NULL ENABLE,
"EMP_LOGIN" VARCHAR2(100 BYTE),
"EMP_EMAIL" VARCHAR2(100 BYTE),
"EMP_LOCATION" VARCHAR2(100 BYTE),
"EMP_GROUP_ID" NUMBER(10,0) NOT NULL ENABLE,
"EMP_PASSWORD" VARCHAR2(100 BYTE),
"EMP_OVERRIDE_GRP" NUMBER DEFAULT 0 NOT NULL ENABLE,
"EMP_YEAR_OF_BIRTH" NUMBER(*,0) DEFAULT 0,
"EMP_EXPERIENCE_SINCE" NUMBER(*,0) DEFAULT 0,
"EMP_EXTERN" NUMBER(1,0) DEFAULT 0 NOT NULL ENABLE
)
Here is the
persistence.xml:
Code:
<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="MyAppPersistence"
transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/MyAppDS</jta-data-source>
<properties>
...
<property name="hibernate.hbm2ddl.auto" value="validate" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
<property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver" />
<property name="hibernate.transaction.manager_lookup_class"
value="org.hibernate.transaction.JBossTransactionManagerLookup" />
</properties>
</persistence-unit>
</persistence>
And this is the Entity
Employee.java:
Code:
@Entity
@Indexed
@Table( name = "EMPLOYEE" )
public class Employee
{
// other fields omitted
@Column( name = "EMP_EXTERN", nullable = false )
private boolean extern;
// getters and setters omitted
}
I haven't found this issue yet. With Hibernate 3 this error wasn't present with the same schema and entity.
Does anybody have an idea what's going wrong?