Hibernate + netbeans

Quando mando compilar o meu projeto (build), recebo a seguinte mensagem

extension-library-variants: init: deps-clean: Deleting directory /home/usuario/workspace/Diagon/build Deleting directory /home/usuario/workspace/Diagon/dist clean: extension-library-variants: init: deps-jar: Created dir: /home/usuario/workspace/Diagon/build/classes project-extension-init: xdoclet-hibernate: 17/11/2006 09:42:57 xdoclet.XDocletMain start INFO: Running <hibernate/> Generating mapping file for dao.User. dao.User xdoclet-hibernate-build: Compiling 19 source files to /home/usuario/workspace/Diagon/build/classes Note: /home/usuario/workspace/Diagon/src/dao/HibernateUtil.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. Copying 66 files to /home/usuario/workspace/Diagon/build/classes hibernate-test-user-props: hibernate-load-user-props: hibernate-resources: compile: hibernate-schema-export: 17/11/2006 09:42:59 org.hibernate.cfg.Environment <clinit> INFO: Hibernate 3.2.0 17/11/2006 09:42:59 org.hibernate.cfg.Environment <clinit> INFO: hibernate.properties not found 17/11/2006 09:42:59 org.hibernate.cfg.Environment buildBytecodeProvider INFO: Bytecode provider name : cglib 17/11/2006 09:42:59 org.hibernate.cfg.Environment <clinit> INFO: using JDK 1.4 java.sql.Timestamp handling 17/11/2006 09:42:59 org.hibernate.cfg.Configuration addFile INFO: Reading mappings from file: /home/usuario/workspace/Diagon/build/classes/dao/User.hbm.xml 17/11/2006 09:42:59 org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues INFO: Mapping class: dao.User -> USER 17/11/2006 09:42:59 org.hibernate.dialect.Dialect <init> INFO: Using dialect: org.hibernate.dialect.HSQLDialect 17/11/2006 09:43:00 org.hibernate.tool.hbm2ddl.SchemaExport execute INFO: Running hbm2ddl schema export 17/11/2006 09:43:00 org.hibernate.tool.hbm2ddl.SchemaExport execute INFO: writing generated schema to file: /home/usuario/workspace/Diagon/build/schema-export.sql 17/11/2006 09:43:00 org.hibernate.tool.hbm2ddl.SchemaExport execute INFO: exporting generated schema to database 17/11/2006 09:43:00 org.hibernate.connection.DriverManagerConnectionProvider configure INFO: Using Hibernate built-in connection pool (not for production use!) 17/11/2006 09:43:00 org.hibernate.connection.DriverManagerConnectionProvider configure INFO: Hibernate connection pool size: 20 17/11/2006 09:43:00 org.hibernate.connection.DriverManagerConnectionProvider configure INFO: autocommit mode: false 17/11/2006 09:43:00 org.hibernate.connection.DriverManagerConnectionProvider configure INFO: using driver: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:file:Diagon 17/11/2006 09:43:00 org.hibernate.connection.DriverManagerConnectionProvider configure INFO: connection properties: {user=SA, password=****} 17/11/2006 09:43:00 org.hibernate.tool.hbm2ddl.SchemaExport execute SEVERE: schema export unsuccessful java.sql.SQLException: Wrong database file version at org.hsqldb.jdbc.jdbcUtil.sqlException(Unknown Source) at org.hsqldb.jdbc.jdbcConnection.<init>(Unknown Source) at org.hsqldb.jdbcDriver.getConnection(Unknown Source) at org.hsqldb.jdbcDriver.connect(Unknown Source) at java.sql.DriverManager.getConnection(DriverManager.java:525) at java.sql.DriverManager.getConnection(DriverManager.java:140) at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110) at org.hibernate.tool.hbm2ddl.ManagedProviderConnectionHelper.prepare(ManagedProviderConnectionHelper.java:28) at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:180) at org.hibernate.tool.hbm2ddl.SchemaExportTask.execute(SchemaExportTask.java:146) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275) at org.apache.tools.ant.Task.perform(Task.java:364) at org.apache.tools.ant.Target.execute(Target.java:341) at org.apache.tools.ant.Target.performTasks(Target.java:369) at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1216) at org.apache.tools.ant.Project.executeTarget(Project.java:1185) at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:40) at org.apache.tools.ant.Project.executeTargets(Project.java:1068) at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:240) at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:293) at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:131) hibernate-schema-export-build: Created dir: /home/usuario/workspace/Diagon/dist Building jar: /home/usuario/workspace/Diagon/dist/Diagon.jar jar: BUILD SUCCESSFUL (total time: 3 seconds)

já apaguei o arquivo do banco de dados e criei um novo, o que devo fazer?

OBS: estou usando HSQLDB

hi,

As versões do seu driver jdbc e o banco são compatíveis?

Schmidt

eu apaguei o arquivo gerado pelo hsqldb e ele criou de novo sem problemas, mas continuo sem conseguir acessar as tabelas :frowning:

[quote=schmidt]hi,

As versões do seu driver jdbc e o banco são compatíveis?

Schmidt[/quote]

você tinha razão, as versões estavam diferentes (a do plugin e a que baixei).
agora estou com o seguinte problema.
criei a seguinte tabela.

CREATE MEMORY TABLE "User"("id" INTEGER NOT NULL PRIMARY KEY,"name" VARCHAR)

e fiz o seguinte arquivo .hbm.xml

[code]
package dao ;
/**
*
*

  • @hibernate.class
  • table="USER"
    

*/
public class User {

//
private String name;
/**

  • @hibernate.property
  • column="name"
    
  • type="java.lang.String"
    
  • @hibernate.column
  • name="name"
    

*/
public String getName () {
return name;
}
public void setName (String name) {
this.name = name;
}
//

//
private Long codUser;
/**

  • @hibernate.id
  • generator-class="uuid.hex"
    
  • column="codUser"
    
  • type="long"
    
  • @hibernate.column
  • name="codUser"
    
  • not-null="false"
    

*/
public Long getCodUser () {
return codUser;
}
public void setCodUser (Long codUser) {
this.codUser = codUser;
}
//
}[/code]

também fiz um arquivo facade

[code]package dao;

import org.hibernate.Session;
import org.hibernate.Transaction;

/**

  • @netbeans.hibernate.facade beanClass=dao.User
    */
    public class UserFacade {
    public void saveUser(User user) {
    Session session = dao.HibernateUtil.currentSession();
    Transaction tx = session.beginTransaction();
    session.save(user);
    tx.commit();
    dao.HibernateUtil.closeSession();
    }

    public void generate() {
    User user = new User();
    user.setCodUser(new Long(0));
    user.setName(“alex”);
    saveUser(user);
    }
    }[/code]

mas quando executo o método generate do facade, recebo o seguinte erro

extension-library-variants: init: deps-jar: project-extension-init: xdoclet-hibernate: 17/11/2006 11:21:21 xdoclet.XDocletMain start INFO: Running <hibernate/> Generating mapping file for dao.User. dao.User xdoclet-hibernate-build: Compiling 1 source file to /home/usuario/workspace/Diagon/build/classes hibernate-test-user-props: hibernate-load-user-props: hibernate-resources: compile: log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment). log4j:WARN Please initialize the log4j system properly. Exception in thread "main" org.hibernate.PropertyAccessException: IllegalArgumentException occurred while calling setter of dao.User.codUser at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:104) at org.hibernate.tuple.entity.AbstractEntityTuplizer.setIdentifier(AbstractEntityTuplizer.java:211) at org.hibernate.persister.entity.AbstractEntityPersister.setIdentifier(AbstractEntityPersister.java:3529) at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:170) at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:121) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:186) at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:175) at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) at org.hibernate.impl.SessionImpl.fireSave(SessionImpl.java:535) at org.hibernate.impl.SessionImpl.save(SessionImpl.java:523) at org.hibernate.impl.SessionImpl.save(SessionImpl.java:519) at dao.UserFacade.saveUser(UserFacade.java:13) at dao.UserFacade.generate(UserFacade.java:22) at diagon.Main.<init>(Main.java:23) at diagon.Main.main(Main.java:32) Caused by: java.lang.IllegalArgumentException: argument type mismatch at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.hibernate.property.BasicPropertyAccessor$BasicSetter.set(BasicPropertyAccessor.java:42) ... 16 more Java Result: 1 debug: BUILD SUCCESSFUL (total time: 6 seconds)

você tem alguma idéia? :wink: