GUJ
Notícias, artigos e o maior fórum brasileiro sobre Java
home
fórum
notícias
tópicos recentes
empregos
artigos
Bem-vindo ao GUJ.
Crie seu login
, ou digite-o para logar no site.
Usuário:
Senha:
Mapear tabela com anotações
Índice dos Fóruns
»
Java Avançado
Autor
Mensagem
13/07/2006 16:24:02
Assunto:
Mapear tabela com anotações
sigma
Thread.start()
Membro desde: 07/07/2005 17:47:11
Mensagens: 42
Offline
Para mapear a tabela do banco usando hibernate com anotacoes basta fazer o seguinte codigo?
@Entity @Table(appliesTo="amigos") public class Amigo implements Serializable { ...propriedades e metodos... }
Esta dando erro quando tento inserir ou listar.
ps: quando coloco o nome da tabela o mesmo da classe tudo funciona, isso e o default
13/07/2006 16:12:15 org.hibernate.cfg.annotations.Version <clinit> INFO: Hibernate Annotations 3.2.0.CR1 13/07/2006 16:12:15 org.hibernate.cfg.Environment <clinit> INFO: Hibernate 3.2 cr2 13/07/2006 16:12:15 org.hibernate.cfg.Environment <clinit> INFO: loaded properties from resource hibernate.properties: {hibernate.connection.username=sa, hibernate.connection.password=****, hibernate.dialect=org.hibernate.dialect.SQLServerDialect, hibernate.connection.url=jdbc:jtds:sqlserver://svr_bancoteste:1433/northwind, hibernate.bytecode.use_reflection_optimizer=false, hibernate.connection.driver_class=net.sourceforge.jtds.jdbc.Driver} 13/07/2006 16:12:15 org.hibernate.cfg.Environment buildBytecodeProvider INFO: Bytecode provider name : cglib 13/07/2006 16:12:15 org.hibernate.cfg.Environment <clinit> INFO: using JDK 1.4 java.sql.Timestamp handling 13/07/2006 16:12:16 org.hibernate.cfg.AnnotationBinder bindClass INFO: Binding entity from annotated class: com.amigos.entidades.Amigo 13/07/2006 16:12:16 org.hibernate.cfg.annotations.EntityBinder bindTable INFO: Bind entity com.amigos.entidades.Amigo on table Amigo 13/07/2006 16:12:16 org.hibernate.connection.DriverManagerConnectionProvider configure INFO: Using Hibernate built-in connection pool (not for production use!) 13/07/2006 16:12:16 org.hibernate.connection.DriverManagerConnectionProvider configure INFO: Hibernate connection pool size: 20 13/07/2006 16:12:16 org.hibernate.connection.DriverManagerConnectionProvider configure INFO: autocommit mode: false 13/07/2006 16:12:16 org.hibernate.connection.DriverManagerConnectionProvider configure INFO: using driver: net.sourceforge.jtds.jdbc.Driver at URL: jdbc:jtds:sqlserver://svr_bancoteste:1433/northwind 13/07/2006 16:12:16 org.hibernate.connection.DriverManagerConnectionProvider configure INFO: connection properties: {user=sa, password=****} 13/07/2006 16:12:17 org.hibernate.cfg.SettingsFactory buildSettings INFO: RDBMS: Microsoft SQL Server, version: 07.00.01094 13/07/2006 16:12:17 org.hibernate.cfg.SettingsFactory buildSettings INFO: JDBC driver: jTDS Type 4 JDBC Driver for MS SQL Server, version: 0.7 13/07/2006 16:12:17 org.hibernate.dialect.Dialect <init> INFO: Using dialect: org.hibernate.dialect.SQLServerDialect 13/07/2006 16:12:17 org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory INFO: Using default transaction strategy (direct JDBC transactions) 13/07/2006 16:12:17 org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended) 13/07/2006 16:12:17 org.hibernate.cfg.SettingsFactory buildSettings INFO: Automatic flush during beforeCompletion(): disabled 13/07/2006 16:12:17 org.hibernate.cfg.SettingsFactory buildSettings INFO: Automatic session close at end of transaction: disabled 13/07/2006 16:12:17 org.hibernate.cfg.SettingsFactory buildSettings INFO: Scrollable result sets: enabled 13/07/2006 16:12:17 org.hibernate.cfg.SettingsFactory buildSettings INFO: JDBC3 getGeneratedKeys(): enabled 13/07/2006 16:12:17 org.hibernate.cfg.SettingsFactory buildSettings INFO: Connection release mode: auto 13/07/2006 16:12:17 org.hibernate.cfg.SettingsFactory buildSettings INFO: Default batch fetch size: 1 13/07/2006 16:12:17 org.hibernate.cfg.SettingsFactory buildSettings INFO: Generate SQL with comments: disabled 13/07/2006 16:12:17 org.hibernate.cfg.SettingsFactory buildSettings INFO: Order SQL updates by primary key: disabled 13/07/2006 16:12:17 org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory 13/07/2006 16:12:17 org.hibernate.hql.ast.ASTQueryTranslatorFactory <init> INFO: Using ASTQueryTranslatorFactory 13/07/2006 16:12:17 org.hibernate.cfg.SettingsFactory buildSettings INFO: Query language substitutions: {} 13/07/2006 16:12:17 org.hibernate.cfg.SettingsFactory buildSettings INFO: Second-level cache: enabled 13/07/2006 16:12:17 org.hibernate.cfg.SettingsFactory buildSettings INFO: Query cache: disabled 13/07/2006 16:12:17 org.hibernate.cfg.SettingsFactory createCacheProvider INFO: Cache provider: org.hibernate.cache.EhCacheProvider 13/07/2006 16:12:17 org.hibernate.cfg.SettingsFactory buildSettings INFO: Optimize cache for minimal puts: disabled 13/07/2006 16:12:17 org.hibernate.cfg.SettingsFactory buildSettings INFO: Structured second-level cache entries: disabled 13/07/2006 16:12:17 org.hibernate.cfg.SettingsFactory buildSettings INFO: Statistics: disabled 13/07/2006 16:12:17 org.hibernate.cfg.SettingsFactory buildSettings INFO: Deleted entity synthetic identifier rollback: disabled 13/07/2006 16:12:17 org.hibernate.cfg.SettingsFactory buildSettings INFO: Default entity-mode: pojo 13/07/2006 16:12:17 org.hibernate.impl.SessionFactoryImpl <init> INFO: building session factory 13/07/2006 16:12:17 net.sf.ehcache.config.ConfigurationFactory parseConfiguration WARNING: No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/C:/java/ferramentas/hibernate/hibernate-3.2/lib/ehcache-1.2.jar!/ehcache-failsafe.xml 13/07/2006 16:12:18 org.hibernate.impl.SessionFactoryObjectFactory addInstance INFO: Not binding factory to JNDI, no JNDI name configured 13/07/2006 16:12:18 org.hibernate.util.JDBCExceptionReporter logExceptions WARNING: SQL Error: 208, SQLState: S1000 13/07/2006 16:12:18 org.hibernate.util.JDBCExceptionReporter logExceptions SEVERE: Invalid object name 'Amigo'. org.hibernate.exception.GenericJDBCException: could not retrieve snapshot: [com.amigos.entidades.Amigo#Sergio Ricardo Moraes3773] at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103) at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.persister.entity.AbstractEntityPersister.getDatabaseSnapshot(AbstractEntityPersister.java:1030) at org.hibernate.engine.StatefulPersistenceContext.getDatabaseSnapshot(StatefulPersistenceContext.java:232) at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:189) at org.hibernate.event.def.AbstractSaveEventListener.getEntityState(AbstractSaveEventListener.java:487) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:84) at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70) at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl.java:509) at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:501) at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:497) at com.amigos.dao.AmigoDAO.insert(AmigoDAO.java:15) at Main.main(Main.java:23) Caused by: java.sql.SQLException: Invalid object name 'Amigo'. at net.sourceforge.jtds.jdbc.SqlMessage.toSQLException(SqlMessage.java:85) at net.sourceforge.jtds.jdbc.SQLWarningChain.addOrReturn(SQLWarningChain.java:99) at net.sourceforge.jtds.jdbc.Tds.goToNextResult(Tds.java:837) at net.sourceforge.jtds.jdbc.TdsStatement.getMoreResults(TdsStatement.java:707) at net.sourceforge.jtds.jdbc.TdsStatement.executeCallImpl(TdsStatement.java:301) at net.sourceforge.jtds.jdbc.TdsStatement.internalExecuteCall(TdsStatement.java:281) at net.sourceforge.jtds.jdbc.PreparedStatement_base.execute(PreparedStatement_base.java:133) at net.sourceforge.jtds.jdbc.PreparedStatement_base.executeQuery(PreparedStatement_base.java:258) at org.hibernate.persister.entity.AbstractEntityPersister.getDatabaseSnapshot(AbstractEntityPersister.java:1003) ... 10 more
13/07/2006 19:20:24
Assunto:
Re:Mapear tabela com anotações
Guilherme Moreira
JavaChild
Membro desde: 27/03/2006 12:55:44
Mensagens: 112
Offline
importe de javax.persistence
www.caelum.com.br
Índice dos Fóruns
»
Java Avançado
Ir para:
Selecione um Fórum
Notícias
Assuntos gerais (Off-topic)
MundoJ - Artigos, Notícias e Debates
Artigos e Tutoriais
Java Básico
Java Avançado
Ferramentas, Frameworks e Utilitários
Desenvolvimento Web
Interface Gráfica
Google Android e Java Micro Edition (ME)
Certificação Java
Persistência: Hibernate, JPA, JDBC e outros
Java Enterprise Edition (Java EE)
Frameworks e Bibliotecas brasileiros
RIA - Flex, JavaFX e outros
Arquitetura de Sistemas
Metodologias de Desenvolvimento e Testes de Software
JavaScript
Ruby & Ruby on Rails
Outras Linguagens
Powered by
JForum 2.1.8
©
JForum Team