Uso hibernate com Dialect ...erro "Dialect does not support identity key generation"

1 resposta
P

Olá,

não consigo visualizar o erro conform main rodado abaixo …

Estou usando Oracle10G , e o jar é o ojdbc14.jar …

Se alguém puder me ajudar …

abs

public static void main(String[] args) {
		// TODO Auto-generated method stub
		System.out.println("Vai criar o banco");
		emf = Persistence.createEntityManagerFactory("create_JPA9");
		System.out.println("Final  criação do banco");
	}
<persistence-unit name="create_JPA9">
                <description>
                        Exemplo simples de persistência usando JPA. 
                </description>
                <provider>org.hibernate.ejb.HibernatePersistence</provider>
    
                <properties>
                        <property name="hibernate.archive.autodetetion" value="class"/>
                        <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
                        <property name="hibernate.connection.driver_class"  value="oracle.jdbc.driver.OracleDriver" />
                        <property name="hibernate.connection.username" value="ims" />
                        <property name="hibernate.connection.password" value="ims" />
                        <property name="hibernate.connection.url" value="jdbc:oracle:thin:@192.168.1.247:1521:orcl" />
                        <property name="hibernate.show_sql" value="true"/>  
                        <property name="hibernate.hbm2ddl.auto" value="create-drop" />  
                        <property name="hibernate.format_sql" value="true"/>   
                                       
                </properties>
        </persistence-unit>
- Not binding factory to JNDI, no JNDI name configured
Exception in thread "main" javax.persistence.PersistenceException: [PersistenceUnit: create_JPA9] Unable to build EntityManagerFactory
	at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:677)
	at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:126)
	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:52)
	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:34)
	at br.com.exemplojpa.teste.Cria_Banco.main(Cria_Banco.java:31)
Caused by: org.hibernate.MappingException: Dialect does not support identity key generation
	at org.hibernate.dialect.Dialect.getIdentityColumnString(Dialect.java:548)
	at org.hibernate.dialect.Dialect.getIdentityColumnString(Dialect.java:538)
	at org.hibernate.mapping.Table.sqlCreateString(Table.java:392)
	at org.hibernate.cfg.Configuration.generateSchemaCreationScript(Configuration.java:854)
	at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:74)
	at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:311)
	at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1300)
	at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:859)
	at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:669)
	... 4 more

1 Resposta

T

-> http://docs.jboss.org/hibernate/stable/core/reference/en/html/mapping.html#mapping-declaration-id-generator

Dica: troque "identity" por "native", aí o Hibernate escolhe "identity", "sequence" ou "hilo" conforme o banco de dados a ser usado.

Criado 8 de junho de 2009
Ultima resposta 8 de jun. de 2009
Respostas 1
Participantes 2