Ajuda com Hibernate

valeu cara isso resolveu essa questao do log4j, parece que o mapeamento estah sendo feito corretamente, mas parece q o arquivo de configuracao do banco de dados naum estah sendo lido

2004-07-30 13:50:29,918 INFO hibernate.cfg.Environment -> Hibernate 2.1.3
2004-07-30 13:50:29,946 INFO hibernate.cfg.Environment -> hibernate.properties not found
2004-07-30 13:50:29,974 INFO hibernate.cfg.Environment -> using CGLIB reflection optimizer
2004-07-30 13:50:30,073 INFO hibernate.cfg.Configuration -> Mapping resource: Amigo.hbm.xml
2004-07-30 13:50:32,672 DEBUG hibernate.util.DTDEntityResolver -> trying to locate http://hibernate.sourceforge.net/hibernate-mapping.dtd in classpath under net/sf/hibernate/
2004-07-30 13:50:32,681 DEBUG hibernate.util.DTDEntityResolver -> http://hibernate.sourceforge.net/hibernate-mapping.dtdnot found in classpath
2004-07-30 13:50:35,266 INFO hibernate.cfg.Binder -> Mapping class: Amigo -> amigos
2004-07-30 13:50:35,899 DEBUG hibernate.cfg.Binder -> Mapped property: nome -> nome, type: string
2004-07-30 13:50:36,041 DEBUG hibernate.cfg.Binder -> Mapped property: endereco -> endereco, type: string
2004-07-30 13:50:36,043 DEBUG hibernate.cfg.Binder -> Mapped property: telefone -> fone, type: string
2004-07-30 13:50:36,045 DEBUG hibernate.cfg.Binder -> Mapped property: celular -> cel, type: string
2004-07-30 13:50:36,046 DEBUG hibernate.cfg.Binder -> Mapped property: email -> email, type: string
2004-07-30 13:50:36,048 DEBUG hibernate.cfg.Binder -> Mapped property: nascimento -> nascimento, type: date
2004-07-30 13:50:36,050 INFO hibernate.cfg.Configuration -> processing one-to-many association mappings
2004-07-30 13:50:36,051 INFO hibernate.cfg.Configuration -> processing one-to-one association property references
2004-07-30 13:50:36,052 INFO hibernate.cfg.Configuration -> processing foreign key constraints
2004-07-30 13:50:36,270 WARN hibernate.cfg.SettingsFactory -> No dialect set - using GenericDialect: The dialect was not set. Set the property hibernate.dialect.
2004-07-30 13:50:36,282 INFO hibernate.dialect.Dialect -> Using dialect: net.sf.hibernate.dialect.GenericDialect
2004-07-30 13:50:36,285 INFO hibernate.cfg.SettingsFactory -> Use outer join fetching: false
2004-07-30 13:50:36,373 WARN hibernate.connection.UserSuppliedConnectionProvider -> No connection properties specified - the user must supply JDBC connections
2004-07-30 13:50:36,465 INFO hibernate.transaction.TransactionManagerLookupFactory -> No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
2004-07-30 13:50:36,469 INFO hibernate.cfg.SettingsFactory -> Use scrollable result sets: false
2004-07-30 13:50:36,472 INFO hibernate.cfg.SettingsFactory -> Use JDBC3 getGeneratedKeys(): false
2004-07-30 13:50:36,473 INFO hibernate.cfg.SettingsFactory -> Optimize cache for minimal puts: false
2004-07-30 13:50:36,475 INFO hibernate.cfg.SettingsFactory -> Query language substitutions: {}
2004-07-30 13:50:36,477 INFO hibernate.cfg.SettingsFactory -> cache provider: net.sf.ehcache.hibernate.Provider
2004-07-30 13:50:36,495 INFO hibernate.cfg.Configuration -> instantiating and configuring caches
2004-07-30 13:50:37,648 INFO hibernate.impl.SessionFactoryImpl -> building session factory
2004-07-30 13:50:37,652 DEBUG hibernate.impl.SessionFactoryImpl -> instantiating session factory with properties: {java.runtime.name=Java™ 2 Runtime Environment, Standard Edition, sun.boot.library.path=/usr/local/j2sdk1.4.2_04/jre/lib/i386, java.vm.version=1.4.2_04-b05, java.vm.vendor=Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=:, java.vm.name=Java HotSpot™ Client VM, file.encoding.pkg=sun.io, user.country=US, sun.os.patch.level=unknown, java.vm.specification.name=Java Virtual Machine Specification, user.dir=/xmlrpc, java.runtime.version=1.4.2_04-b05, java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment, java.endorsed.dirs=/usr/local/j2sdk1.4.2_04/jre/lib/endorsed, os.arch=i386, java.io.tmpdir=/tmp, line.separator=
, java.vm.specification.vendor=Sun Microsystems Inc., os.name=Linux, sun.java2d.fontpath=, java.library.path=/usr/local/j2sdk1.4.2_04/jre/lib/i386/client:/usr/local/j2sdk1.4.2_04/jre/lib/i386:/usr/local/j2sdk1.4.2_04/jre/…/lib/i386:/opt/kde/lib, java.specification.name=Java Platform API Specification, java.class.version=48.0, java.util.prefs.PreferencesFactory=java.util.prefs.FileSystemPreferencesFactory, os.version=2.4.5, user.home=/root, user.timezone=America/Sao_Paulo, java.awt.printerjob=sun.print.PSPrinterJob, file.encoding=ANSI_X3.4-1968, java.specification.version=1.4, user.name=root, java.class.path=.:/usr/local/jakarta-log4j-1.2.8/dist/lib/log4j-1.2.8.jar:/usr/local/j2ssh/dist/lib/j2ssh-core.jar:/usr/local/j2ssh/lib:/usr/local/j2ssh/dist/lib:/usr/local/java_xml_pack-summer-02_01/jaxp-1.2_01/jaxp-api.jar:/usr/local/xmlrpc-1.2-b1/xmlrpc-1.2-b1.jar:/usr/local/jdom-b10/build/jdom.jar:/usr/local/src/hibernate/hibernate-2.1/lib:/usr/local/src/hibernate/hibernate-2.1/lib/dom4j-1.4.jar:/xmlrpc/libs, java.vm.specification.version=1.0, java.home=/usr/local/j2sdk1.4.2_04/jre, sun.arch.data.model=32, user.language=en, java.specification.vendor=Sun Microsystems Inc., hibernate.cglib.use_reflection_optimizer=true, java.vm.info=mixed mode, java.version=1.4.2_04, java.ext.dirs=/usr/local/j2sdk1.4.2_04/jre/lib/ext, sun.boot.class.path=/usr/local/j2sdk1.4.2_04/jre/lib/endorsed/sax2.jar:/usr/local/j2sdk1.4.2_04/jre/lib/rt.jar:/usr/local/j2sdk1.4.2_04/jre/lib/i18n.jar:/usr/local/j2sdk1.4.2_04/jre/lib/sunrsasign.jar:/usr/local/j2sdk1.4.2_04/jre/lib/jsse.jar:/usr/local/j2sdk1.4.2_04/jre/lib/jce.jar:/usr/local/j2sdk1.4.2_04/jre/lib/charsets.jar:/usr/local/j2sdk1.4.2_04/jre/classes, java.vendor=Sun Microsystems Inc., file.separator=/, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, sun.io.unicode.encoding=UnicodeLittle, sun.cpu.endian=little, sun.cpu.isalist=}
2004-07-30 13:50:40,117 DEBUG hibernate.impl.SessionFactoryObjectFactory -> initializing class SessionFactoryObjectFactory
2004-07-30 13:50:40,142 DEBUG hibernate.impl.SessionFactoryObjectFactory -> registered: 40288092fe10f5ca00fe10f5d7610000 (unnamed)
2004-07-30 13:50:40,145 INFO hibernate.impl.SessionFactoryObjectFactory -> no JNDI name configured
2004-07-30 13:50:40,147 DEBUG hibernate.impl.SessionFactoryImpl -> instantiated session factory
2004-07-30 13:50:40,726 DEBUG hibernate.impl.SessionImpl -> opened session
2004-07-30 13:50:40,743 DEBUG hibernate.impl.SessionImpl -> generated identifier: Anselmo
2004-07-30 13:50:40,753 DEBUG hibernate.impl.SessionImpl -> saving [Amigo#Anselmo]
2004-07-30 13:50:40,879 DEBUG hibernate.impl.SessionImpl -> flushing session
2004-07-30 13:50:40,907 DEBUG hibernate.impl.SessionImpl -> Flushing entities and processing referenced collections
2004-07-30 13:50:40,924 DEBUG hibernate.impl.SessionImpl -> Processing unreferenced collections
2004-07-30 13:50:40,926 DEBUG hibernate.impl.SessionImpl -> Scheduling collection removes/(re)creates/updates
2004-07-30 13:50:40,929 DEBUG hibernate.impl.SessionImpl -> Flushed: 1 insertions, 0 updates, 0 deletions to 1 objects
2004-07-30 13:50:40,930 DEBUG hibernate.impl.SessionImpl -> Flushed: 0 (re)creations, 0 updates, 0 removals to 0 collections
2004-07-30 13:50:40,943 DEBUG hibernate.impl.Printer -> listing entities:
2004-07-30 13:50:41,252 DEBUG hibernate.impl.Printer -> Amigo{nome=Anselmo, celular=91231203, email=anselmo@bol.com.br, telefone=2134567, nascimento=29 August 2004, endereco=Carlos Kraemer}
2004-07-30 13:50:41,256 DEBUG hibernate.impl.SessionImpl -> executing flush
2004-07-30 13:50:41,268 DEBUG hibernate.persister.EntityPersister -> Inserting entity: [Amigo#Anselmo]
2004-07-30 13:50:41,271 DEBUG hibernate.impl.BatcherImpl -> about to open: 0 open PreparedStatements, 0 open ResultSets
Exception in thread “main” java.lang.UnsupportedOperationException: The user must supply a JDBC connection
at net.sf.hibernate.connection.UserSuppliedConnectionProvider.getConnection(UserSuppliedConnectionProvider.java:32)
at net.sf.hibernate.impl.BatcherImpl.openConnection(BatcherImpl.java:278)
at net.sf.hibernate.impl.SessionImpl.connect(SessionImpl.java:3297)
at net.sf.hibernate.impl.SessionImpl.connection(SessionImpl.java:3277)
at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:61)
at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:56)
at net.sf.hibernate.impl.BatcherImpl.prepareBatchStatement(BatcherImpl.java:109)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:460)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:442)
at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:29)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2407)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2360)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2229)
at AmigoDAO.insert(AmigoDAO.java:21)
at Chama.main(Chama.java:14)

vc sabe o q posso fazer?

vc sabe se na versao 2 do hibernate se eu nomear o arquivo como hibernate.properties e coloca-lo no CLASSPATH ele carrega automaticamente? ou tenho q chama-lo em algum ponto?

valeu…

Eu se fosse vc criaria a conexão na mão e passaria por parametro para o openSession… Ai veria se isso funcionava… se funcionar o problema deve estar no classpath mesmo!!!

me desculpe, mas como disse no inicio sou iniciante e naum sei como fazer essa conexao na mao q vc falou…

valeu…

De uma olhada no tutorial aqui do GUJ em :
http://www.guj.com.br/user.article.get.chain?page=1&article.id=7

Ali vc ve como pegar uma connection com o DriverManager…

Fallow

meu grande problema estah aqui embaixo, se eu conseguir fazer o hibernate ler esse arquivo de propriedades…

2004-07-30 13:50:29,946 INFO hibernate.cfg.Environment -> hibernate.properties not found

mas jah tentei de tudo, cloloquei esse arquivo onde estaum todos os demais, coloquei em ./libs, sendo q esta estah no CLASSPATH, tentei tb colocar no j2sdk/jre/lib/ext…mas nada disso funcionou…

Jah estou quase no final do segundo dia e infelizmente naum coloquei esse hibernate a funcionar…jah encontrei em outros locais na net pessoas com problemas identicos ao meu, mas ainda naum encontrei as solucoes…

Coloque na raiz de sua estrutura para tentar salvar o dia.

Ex.:
pasta - > br -> com -> abc
hibernate.properties

pois eh…jah fiz isso tb, alem de tudo o q citei no post anterior…jah toh ficando maluco…
Passos q fiz:

  1. coloquei o hibernate.properties onde estah a minha aplicacao
  2. $RAIZ_APLICACAO/libs
  3. j2sdk/jre/lib/ext

sendo q essas 3 localizacoes estao no CLASSPATH,

alem disso, tentei:

  1. renomear o arquivo pro mesmo nome do objeto(amigo.properties)
  2. o mesmo, mas iniciando com A(maiusculo) -> Amigo.properties
  3. tentei tb Hibernate.properties

como podem ver estou no desespero…e a solucao pra variar deve ser ridicula…soh q ainda naum a encontrei…:frowning:

valeu…