Duvida para criar o hbm.xml

10 respostas
0

está dando esse erro

run:
15/01/2010 14:27:21 org.slf4j.impl.JCLLoggerAdapter info
INFO: Hibernate 3.5.0-Beta-3
15/01/2010 14:27:21 org.slf4j.impl.JCLLoggerAdapter info
INFO: hibernate.properties not found
15/01/2010 14:27:21 org.slf4j.impl.JCLLoggerAdapter info
INFO: Bytecode provider name : javassist
15/01/2010 14:27:21 org.slf4j.impl.JCLLoggerAdapter info
INFO: using JDK 1.4 java.sql.Timestamp handling
15/01/2010 14:27:21 org.slf4j.impl.JCLLoggerAdapter info
INFO: configuring from resource: /hibernate.cfg.xml
15/01/2010 14:27:21 org.slf4j.impl.JCLLoggerAdapter info
INFO: Configuration resource: /hibernate.cfg.xml
15/01/2010 14:27:21 org.slf4j.impl.JCLLoggerAdapter info
INFO: Reading mappings from resource : gerenciador/Amigo.hbm.xml
15/01/2010 14:27:21 org.slf4j.impl.JCLLoggerAdapter error
SEVERE: Error parsing XML: XML InputStream(4) The content of element type "class" is incomplete, it must match "(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,fetch-profile*,resultset*,(query|sql-query)*)".
15/01/2010 14:27:21 org.slf4j.impl.JCLLoggerAdapter error
SEVERE: Error parsing XML: XML InputStream(9) The content of element type "hibernate-mapping" must match "(meta*,identifier-generator*,typedef*,filter-def*,import*,(class|subclass|joined-subclass|union-subclass)*,resultset*,(query|sql-query)*,filter-def*,fetch-profile*,database-object*)".
Initial SessionFactory creation failed.org.hibernate.InvalidMappingException: Could not parse mapping document from resource gerenciador/Amigo.hbm.xml
Exception in thread "main" java.lang.ExceptionInInitializerError
        at util.HibernateUtil.buildSessionFactory(HibernateUtil.java:18)
        at util.HibernateUtil.<clinit>(HibernateUtil.java:8)
        at gerenciador.Main.main(Main.java:21)
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from resource gerenciador/Amigo.hbm.xml
        at org.hibernate.cfg.Configuration.addResource(Configuration.java:670)
        at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1675)
        at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1643)
        at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1622)
        at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1596)
        at org.hibernate.cfg.Configuration.configure(Configuration.java:1516)
        at org.hibernate.cfg.Configuration.configure(Configuration.java:1502)
        at util.HibernateUtil.buildSessionFactory(HibernateUtil.java:13)
        ... 2 more
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from invalid mapping
        at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:603)
        at org.hibernate.cfg.Configuration.addResource(Configuration.java:667)
        ... 9 more
Caused by: org.xml.sax.SAXParseException: The content of element type "class" is incomplete, it must match "(meta*,subselect?,cache?,synchronize*,comment?,tuplizer*,(id|composite-id),discriminator?,natural-id?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|properties|any|map|set|list|bag|idbag|array|primitive-array)*,((join*,subclass*)|joined-subclass*|union-subclass*),loader?,sql-insert?,sql-update?,sql-delete?,filter*,fetch-profile*,resultset*,(query|sql-query)*)".
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:131)
        at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:384)
        at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:318)
        at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.handleEndElement(XMLDTDValidator.java:2017)
        at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.emptyElement(XMLDTDValidator.java:791)
        at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:377)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2747)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
        at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
        at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:807)
        at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
        at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:107)
        at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
        at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
        at org.dom4j.io.SAXReader.read(SAXReader.java:465)
        at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:600)
        ... 10 more
Java Result: 1
CONSTRUÍDO COM SUCESSO (tempo total: 0 segundos)

meu hbm.xml provavelmentr está errad mas

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
  <class name="gerenciador.Amigo" table="teste"/>
//tirando esse property o resto foi criado pelo assistente de mapeamento do netbeans
<property name="nome"/>
<property name="episodio"/>

</hibernate-mapping>

e o meu hibernate.cfg.xml está assim

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
  <session-factory>
    <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/spiido</property>
    <property name="hibernate.connection.username">root</property>
    <mapping resource="gerenciador/Amigo.hbm.xml"/>
</session-factory>
</hibernate-configuration>

o que ta errado ai?

10 Respostas

marcelo.bellissimo

Precisa ter uma tag <id></id> obrigatoriamente antes dos properties…

Veja bem a mensagem de erro:

Os campos marcados com * ou ? são opcionais, não entrarei em detalhes sobre o significado desses simbolos, mas o único que não contém esses simbolos é o “id” justamente por ele ser o único obrigatório… sério mesmo que foi o assistente de mapeamento do NetBeans que fez isso ?? Meu Deus… falha grave !!! Por isso que eu “adoro” o NetBeans… ¬¬

0

kkk foi sim.... mas olha como ta

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>

    <class name="gerenciador" table="spiido">

        <id name="nome">
            <generator class="native"/>
        </id>

        <property name="episodio"/>

    </class>



</hibernate-mapping>

e o erro que deu

run:
15/01/2010 14:55:27 org.slf4j.impl.JCLLoggerAdapter info
INFO: Hibernate 3.5.0-Beta-3
15/01/2010 14:55:27 org.slf4j.impl.JCLLoggerAdapter info
INFO: hibernate.properties not found
15/01/2010 14:55:27 org.slf4j.impl.JCLLoggerAdapter info
INFO: Bytecode provider name : javassist
15/01/2010 14:55:27 org.slf4j.impl.JCLLoggerAdapter info
INFO: using JDK 1.4 java.sql.Timestamp handling
15/01/2010 14:55:27 org.slf4j.impl.JCLLoggerAdapter info
INFO: configuring from resource: /hibernate.cfg.xml
15/01/2010 14:55:27 org.slf4j.impl.JCLLoggerAdapter info
INFO: Configuration resource: /hibernate.cfg.xml
15/01/2010 14:55:27 org.slf4j.impl.JCLLoggerAdapter info
INFO: Reading mappings from resource : gerenciador/Amigo.hbm.xml
15/01/2010 14:55:28 org.slf4j.impl.JCLLoggerAdapter info
INFO: Mapping class: gerenciador -> spiido
Initial SessionFactory creation failed.org.hibernate.InvalidMappingException: Could not parse mapping document from resource gerenciador/Amigo.hbm.xml
Exception in thread "main" java.lang.ExceptionInInitializerError
        at util.HibernateUtil.buildSessionFactory(HibernateUtil.java:18)
        at util.HibernateUtil.<clinit>(HibernateUtil.java:8)
        at gerenciador.Main.main(Main.java:21)
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from resource gerenciador/Amigo.hbm.xml
        at org.hibernate.cfg.Configuration.addResource(Configuration.java:670)
        at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1675)
        at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1643)
        at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1622)
        at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1596)
        at org.hibernate.cfg.Configuration.configure(Configuration.java:1516)
        at org.hibernate.cfg.Configuration.configure(Configuration.java:1502)
        at util.HibernateUtil.buildSessionFactory(HibernateUtil.java:13)
        ... 2 more
Caused by: org.hibernate.MappingException: class gerenciador not found while looking for property: nome
        at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:232)
        at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:300)
        at org.hibernate.cfg.HbmBinder.bindSimpleId(HbmBinder.java:449)
        at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:382)
        at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:321)
        at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:172)
        at org.hibernate.cfg.Configuration.add(Configuration.java:770)
        at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:605)
        at org.hibernate.cfg.Configuration.addResource(Configuration.java:667)
        ... 9 more
Caused by: java.lang.ClassNotFoundException: gerenciador
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:303)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:169)
        at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:192)
        at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:228)
        ... 17 more
Java Result: 1
CONSTRUÍDO COM SUCESSO (tempo total: 0 segundos)

qual a diferecnça do com o ?

marcelo.bellissimo

Ele tá reclamando que não acha a classe “gerenciador”:

Tenta colocar o caminho completo com pacote e tudo. Tipo assim (substitui o pacote pelo correto ai no seu projeto!) :

Ah, e a classe tá com nome minúsculo mesmo? Geralmente é em maiúsculo…

A diferença entre <id> e <property> é simples…

O <id> representa a chave primária da sua tabela, quer dizer, o atributo que irá servir como o ID do objeto sendo recuperado. Como qualquer chave primária, deve ser único e não-nulo. O Hibernate precisa disso para diferenciar os objetos em sessão.

E <property> são os atributos restantes do objeto …

0

achei um exemplo que tinha que declarar o package que estava etals.. faiz e deu +/- certo

ficou assim

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="gerenciador">

    <class name="Amigo" table="spiido">

        <id name="Nome">
            <generator class="native"/>
        </id>

        <property name="episodio"/>

    </class>



</hibernate-mapping>

mais continuou com um erro

run:
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: Hibernate 3.5.0-Beta-3
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: hibernate.properties not found
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: Bytecode provider name : javassist
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: using JDK 1.4 java.sql.Timestamp handling
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: configuring from resource: /hibernate.cfg.xml
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: Configuration resource: /hibernate.cfg.xml
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: Reading mappings from resource : gerenciador/Amigo.hbm.xml
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: Mapping class: gerenciador.Amigo -> spiido
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: Configured SessionFactory: null
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: Using Hibernate built-in connection pool (not for production use!)
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: Hibernate connection pool size: 20
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: autocommit mode: false
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/spiido
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: connection properties: {user=root}
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: RDBMS: MySQL, version: 5.1.41
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.10 ( Revision: ${svn.Revision} )
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: Using dialect: org.hibernate.dialect.MySQLDialect
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: Using default transaction strategy (direct JDBC transactions)
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: Automatic flush during beforeCompletion(): disabled
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: Automatic session close at end of transaction: disabled
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: JDBC batch size: 15
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: JDBC batch updates for versioned data: disabled
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: Scrollable result sets: enabled
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: JDBC3 getGeneratedKeys(): enabled
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: Connection release mode: auto
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: Maximum outer join fetch depth: 2
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: Default batch fetch size: 1
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: Generate SQL with comments: disabled
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: Order SQL updates by primary key: disabled
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: Order SQL inserts for batching: disabled
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: Using ASTQueryTranslatorFactory
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: Query language substitutions: {}
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: JPA-QL strict compliance: disabled
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: Second-level cache: enabled
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: Query cache: disabled
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: Optimize cache for minimal puts: disabled
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: Structured second-level cache entries: disabled
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: Statistics: disabled
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: Deleted entity synthetic identifier rollback: disabled
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: Default entity-mode: pojo
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: Named query checking : enabled
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: Check Nullability in Core (should be disabled when Bean Validation is on): disabled
15/01/2010 16:03:08 org.slf4j.impl.JCLLoggerAdapter info
INFO: building session factory
15/01/2010 16:03:09 org.slf4j.impl.JCLLoggerAdapter info
INFO: Not binding factory to JNDI, no JNDI name configured
Exception in thread "main" org.hibernate.HibernateException: No CurrentSessionContext configured!
        at org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:666)
        at gerenciador.Main.main(Main.java:21)
Java Result: 1
CONSTRUÍDO COM SUCESSO (tempo total: 1 segundo)

a linha 21 do Main é

Session session = HibernateUtil.getSessionFactory().getCurrentSession();
marcelo.bellissimo

Eita… posta o seu hibernate.cfg.xml , com certeza tá faltando algo… provavelmente as linhas, como essas aqui:

&lt;property name="hibernate.transaction.factory_class"&gt;org.hibernate.transaction.JDBCTransactionFactory&lt;/property&gt; &lt;property name="hibernate.current_session_context_class"&gt;thread&lt;/property&gt;

0

é verdade faltava akilo mesmo mas pus e deu outro erro

run:
15/01/2010 19:41:23 org.slf4j.impl.JCLLoggerAdapter info
INFO: Hibernate 3.5.0-Beta-3
15/01/2010 19:41:23 org.slf4j.impl.JCLLoggerAdapter info
INFO: hibernate.properties not found
15/01/2010 19:41:23 org.slf4j.impl.JCLLoggerAdapter info
INFO: Bytecode provider name : javassist
15/01/2010 19:41:23 org.slf4j.impl.JCLLoggerAdapter info
INFO: using JDK 1.4 java.sql.Timestamp handling
15/01/2010 19:41:23 org.slf4j.impl.JCLLoggerAdapter info
INFO: configuring from resource: /hibernate.cfg.xml
15/01/2010 19:41:23 org.slf4j.impl.JCLLoggerAdapter info
INFO: Configuration resource: /hibernate.cfg.xml
15/01/2010 19:41:23 org.slf4j.impl.JCLLoggerAdapter info
INFO: Reading mappings from resource : gerenciador/Amigo.hbm.xml
15/01/2010 19:41:23 org.slf4j.impl.JCLLoggerAdapter info
INFO: Mapping class: gerenciador.Amigo -> spiido
15/01/2010 19:41:23 org.slf4j.impl.JCLLoggerAdapter info
INFO: Configured SessionFactory: null
15/01/2010 19:41:23 org.slf4j.impl.JCLLoggerAdapter info
INFO: Using Hibernate built-in connection pool (not for production use!)
15/01/2010 19:41:23 org.slf4j.impl.JCLLoggerAdapter info
INFO: Hibernate connection pool size: 20
15/01/2010 19:41:23 org.slf4j.impl.JCLLoggerAdapter info
INFO: autocommit mode: false
15/01/2010 19:41:23 org.slf4j.impl.JCLLoggerAdapter info
INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/spiido
15/01/2010 19:41:23 org.slf4j.impl.JCLLoggerAdapter info
INFO: connection properties: {user=root}
15/01/2010 19:41:24 org.slf4j.impl.JCLLoggerAdapter info
INFO: RDBMS: MySQL, version: 5.1.41
15/01/2010 19:41:24 org.slf4j.impl.JCLLoggerAdapter info
INFO: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.10 ( Revision: ${svn.Revision} )
15/01/2010 19:41:24 org.slf4j.impl.JCLLoggerAdapter info
INFO: Using dialect: org.hibernate.dialect.MySQLDialect
15/01/2010 19:41:24 org.slf4j.impl.JCLLoggerAdapter info
INFO: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4
15/01/2010 19:41:24 org.slf4j.impl.JCLLoggerAdapter info
INFO: Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
15/01/2010 19:41:24 org.slf4j.impl.JCLLoggerAdapter info
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
15/01/2010 19:41:24 org.slf4j.impl.JCLLoggerAdapter info
INFO: Automatic flush during beforeCompletion(): disabled
15/01/2010 19:41:24 org.slf4j.impl.JCLLoggerAdapter info
INFO: Automatic session close at end of transaction: disabled
15/01/2010 19:41:24 org.slf4j.impl.JCLLoggerAdapter info
INFO: JDBC batch size: 15
15/01/2010 19:41:24 org.slf4j.impl.JCLLoggerAdapter info
INFO: JDBC batch updates for versioned data: disabled
15/01/2010 19:41:24 org.slf4j.impl.JCLLoggerAdapter info
INFO: Scrollable result sets: enabled
15/01/2010 19:41:24 org.slf4j.impl.JCLLoggerAdapter info
INFO: JDBC3 getGeneratedKeys(): enabled
15/01/2010 19:41:24 org.slf4j.impl.JCLLoggerAdapter info
INFO: Connection release mode: auto
15/01/2010 19:41:24 org.slf4j.impl.JCLLoggerAdapter info
INFO: Maximum outer join fetch depth: 2
15/01/2010 19:41:24 org.slf4j.impl.JCLLoggerAdapter info
INFO: Default batch fetch size: 1
15/01/2010 19:41:24 org.slf4j.impl.JCLLoggerAdapter info
INFO: Generate SQL with comments: disabled
15/01/2010 19:41:24 org.slf4j.impl.JCLLoggerAdapter info
INFO: Order SQL updates by primary key: disabled
15/01/2010 19:41:24 org.slf4j.impl.JCLLoggerAdapter info
INFO: Order SQL inserts for batching: disabled
15/01/2010 19:41:24 org.slf4j.impl.JCLLoggerAdapter info
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
15/01/2010 19:41:24 org.slf4j.impl.JCLLoggerAdapter info
INFO: Using ASTQueryTranslatorFactory
15/01/2010 19:41:24 org.slf4j.impl.JCLLoggerAdapter info
INFO: Query language substitutions: {}
15/01/2010 19:41:24 org.slf4j.impl.JCLLoggerAdapter info
INFO: JPA-QL strict compliance: disabled
15/01/2010 19:41:24 org.slf4j.impl.JCLLoggerAdapter info
INFO: Second-level cache: enabled
15/01/2010 19:41:24 org.slf4j.impl.JCLLoggerAdapter info
INFO: Query cache: disabled
15/01/2010 19:41:24 org.slf4j.impl.JCLLoggerAdapter info
INFO: Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory
15/01/2010 19:41:24 org.slf4j.impl.JCLLoggerAdapter info
INFO: Optimize cache for minimal puts: disabled
15/01/2010 19:41:24 org.slf4j.impl.JCLLoggerAdapter info
INFO: Structured second-level cache entries: disabled
15/01/2010 19:41:24 org.slf4j.impl.JCLLoggerAdapter info
INFO: Statistics: disabled
15/01/2010 19:41:24 org.slf4j.impl.JCLLoggerAdapter info
INFO: Deleted entity synthetic identifier rollback: disabled
15/01/2010 19:41:24 org.slf4j.impl.JCLLoggerAdapter info
INFO: Default entity-mode: pojo
15/01/2010 19:41:24 org.slf4j.impl.JCLLoggerAdapter info
INFO: Named query checking : enabled
15/01/2010 19:41:24 org.slf4j.impl.JCLLoggerAdapter info
INFO: Check Nullability in Core (should be disabled when Bean Validation is on): disabled
15/01/2010 19:41:24 org.slf4j.impl.JCLLoggerAdapter info
INFO: building session factory
15/01/2010 19:41:24 org.slf4j.impl.JCLLoggerAdapter info
INFO: Not binding factory to JNDI, no JNDI name configured
Exception in thread "main" org.hibernate.TransactionException: Transaction not successfully started
        at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:131)
        at gerenciador.Main.main(Main.java:22)
Java Result: 1

o cfg.xml ta assim

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
  <session-factory>
    <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/spiido</property>
    <property name="hibernate.connection.username">root</property>
    <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
    <property name="hibernate.current_session_context_class">thread</property>
    <mapping resource="gerenciador/Amigo.hbm.xml"/>
</session-factory>
</hibernate-configuration>
marcelo.bellissimo
Agora ele tá reclamando do seu método main, dizendo que a Transaction não foi iniciada:
Exception in thread "main" org.hibernate.TransactionException: Transaction not successfully started   
        at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:131)   
        at gerenciador.Main.main(Main.java:22)
Posta ele aí pra gente ver... ou se quiser, verifique se você está seguindo o fluxo "básico" do Hibernate:
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();

/* faça as suas coisas aqui */

        session.getTransaction().commit();
Mais ou menos isso... sempre iniciando a transação no topo do código... confere aí... qualquer dúvida, recomendo você dar uma lida na documentação do Hibernate, tem muito exemplo e alguns passo-a-passo legais... http://docs.jboss.org/hibernate/stable/core/reference/en/html/
0

EEEEE deu certim :slight_smile:

funcionou

mas é padrão aparece isso??

run: 16/01/2010 13:08:46 org.slf4j.impl.JCLLoggerAdapter info INFO: Hibernate 3.5.0-Beta-3 16/01/2010 13:08:46 org.slf4j.impl.JCLLoggerAdapter info INFO: hibernate.properties not found 16/01/2010 13:08:46 org.slf4j.impl.JCLLoggerAdapter info INFO: Bytecode provider name : javassist 16/01/2010 13:08:46 org.slf4j.impl.JCLLoggerAdapter info INFO: using JDK 1.4 java.sql.Timestamp handling 16/01/2010 13:08:46 org.slf4j.impl.JCLLoggerAdapter info INFO: configuring from resource: /hibernate.cfg.xml 16/01/2010 13:08:46 org.slf4j.impl.JCLLoggerAdapter info INFO: Configuration resource: /hibernate.cfg.xml 16/01/2010 13:08:46 org.slf4j.impl.JCLLoggerAdapter info INFO: Reading mappings from resource : gerenciador/spiido.hbm.xml 16/01/2010 13:08:46 org.slf4j.impl.JCLLoggerAdapter info INFO: Mapping class: gerenciador.spiido -> spiido 16/01/2010 13:08:46 org.slf4j.impl.JCLLoggerAdapter info INFO: Configured SessionFactory: null 16/01/2010 13:08:46 org.slf4j.impl.JCLLoggerAdapter info INFO: Using Hibernate built-in connection pool (not for production use!) 16/01/2010 13:08:46 org.slf4j.impl.JCLLoggerAdapter info INFO: Hibernate connection pool size: 20 16/01/2010 13:08:46 org.slf4j.impl.JCLLoggerAdapter info INFO: autocommit mode: false 16/01/2010 13:08:46 org.slf4j.impl.JCLLoggerAdapter info INFO: using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/spiido 16/01/2010 13:08:46 org.slf4j.impl.JCLLoggerAdapter info INFO: connection properties: {user=root} 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: RDBMS: MySQL, version: 5.1.41 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-5.1.10 ( Revision: ${svn.Revision} ) 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: Using dialect: org.hibernate.dialect.MySQLDialect 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended) 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: Automatic flush during beforeCompletion(): disabled 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: Automatic session close at end of transaction: disabled 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: JDBC batch size: 15 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: JDBC batch updates for versioned data: disabled 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: Scrollable result sets: enabled 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: JDBC3 getGeneratedKeys(): enabled 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: Connection release mode: auto 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: Maximum outer join fetch depth: 2 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: Default batch fetch size: 1 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: Generate SQL with comments: disabled 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: Order SQL updates by primary key: disabled 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: Order SQL inserts for batching: disabled 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: Using ASTQueryTranslatorFactory 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: Query language substitutions: {} 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: JPA-QL strict compliance: disabled 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: Second-level cache: enabled 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: Query cache: disabled 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: Cache region factory : org.hibernate.cache.impl.NoCachingRegionFactory 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: Optimize cache for minimal puts: disabled 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: Structured second-level cache entries: disabled 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: Statistics: disabled 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: Deleted entity synthetic identifier rollback: disabled 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: Default entity-mode: pojo 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: Named query checking : enabled 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: Check Nullability in Core (should be disabled when Bean Validation is on): disabled 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: building session factory 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: Not binding factory to JNDI, no JNDI name configured 1 , teste , teste2 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: closing 16/01/2010 13:08:47 org.slf4j.impl.JCLLoggerAdapter info INFO: cleaning up connection pool: jdbc:mysql://localhost:3306/spiido CONSTRUÍDO COM SUCESSO (tempo total: 2 segundos)

?

o que queria que aparecece era

marcelo.bellissimo

Não entendi… na linha 98 do seu código aparece essa linha que você citou, é isso?

E é normal esse monte de linhas no console, verifique como está configurado o seu log4j.properties …

0

kkkk é isso mesmo

apartir dali mostra os resultados do DB XD

brigadão mesmo o/

Criado 15 de janeiro de 2010
Ultima resposta 16 de jan. de 2010
Respostas 10
Participantes 2