Instale o JBoss Tools no Eclipse usando o Update SiteNo Eclipse Indigo, na barra de menu, clique em Help / Install New SoftwareCole este endereco no campo de texto Work with e clique em Add... http://download.jboss.org/jbosstools/updates/development/indigo/O plugin e obrigatorio o JBoss Data Services / Hibernate Tools, mas e bom instalar todos elesCrie um Hibernate ConfigurationAbra a perspectiva HibernateNo painel Hibernate Configurations, clique com o botao direito em um espaco vazio e va em Add ConfigurationNo campo Project, selecione o projeto onde as classes Java serao criadasNo combo box Database Connection selecione uma conexao MySql existente ou crie uma nova clicando no botao NewNo campo Property file, clique em Setup / Create newNo campo Configuration file, clique em Setup / Create newClique em OKExecute o Hinernate Code GenerationEdite o arquivo hibernate.cfg.xml. Remova a propriedade name na tag session-factory. Deixe-a sem atributos.Adicione o hibernate-tools.jar ao classpath do projeto. Esse jar pode ser encontrado em <eclipse folder> \ plugins \ org.jboss.tools.hibernateextension4_0_3.4.0.v20111213-1944-H40-M5 \ lib \ toolsNa perspectiva Hibernate, na barra de menu, clique em Run / Hibernate Code Generation / Hibernate Code Generation ConfigurationsEm Console configuration, selecione a configuracao recem criadaEm Output directory, selecione a pasta raiz do codigo fonteEm package, preencha com o nome de pacote desejadoEm revenge.xml, clique em Setup / Create newEm reveng. stratagy, Click em Browse e selecione a classe org.hibernate.cfg.reveng.DefaultReverseEngineeringStrategyClique no botao RunVerifique as classes geradasAbra a perspectiva Java EEDe um refresh nos arquivos do projetoVeja que as classes de entidade e DAO foram geradas As vezes um descuido ao editar um arquivo de configuracao pode causar um transtorno enorme, principalmente quando o projeto esta em fase de integracao e com o cronograma apertado.Como um exemplo pratico, um sistema passou a nao conseguir conectar mais com a base de dados de uma hora para outra, sem motivo aparente. A excecao era:Exception in thread "main" org.springframework.transaction.CannotCreateTransactionException: Could not open JPA EntityManager for transaction; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.LockAcquisitionException: Cannot open connection at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:375) at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:374) at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:263) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:101) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171) at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204) at $Proxy18.startBeh(Unknown Source) at br.com.beh.Main.main(Main.java:58)Caused by: javax.persistence.PersistenceException: org.hibernate.exception.LockAcquisitionException: Cannot open connection at org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:614) at org.hibernate.ejb.TransactionImpl.begin(TransactionImpl.java:41) at org.springframework.orm.jpa.DefaultJpaDialect.beginTransaction(DefaultJpaDialect.java:70) at org.springframework.orm.jpa.vendor.HibernateJpaDialect.beginTransaction(HibernateJpaDialect.java:52) at org.springframework.orm.jpa.JpaTransactionManager.doBegin(JpaTransactionManager.java:330) ... 7 moreCaused by: org.hibernate.exception.LockAcquisitionException: Cannot open connection at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:110) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:52) at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:449) at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167) at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:142) at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:85) at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1353) at org.hibernate.ejb.TransactionImpl.begin(TransactionImpl.java:38) ... 10 moreCaused by: java.sql.SQLException: The Network Adapter could not establish the connection at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70) at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:199) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:480) at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:413) at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:508) at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:203) at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:33) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:510) at java.sql.DriverManager.getConnection(DriverManager.java:582) at java.sql.DriverManager.getConnection(DriverManager.java:154) at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriverManager(DriverManagerDataSource.java:174) at org.springframework.jdbc.datasource.DriverManagerDataSource.getConnectionFromDriver(DriverManagerDataSource.java:165) at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnectionFromDriver(AbstractDriverBasedDataSource.java:149) at org.springframework.jdbc.datasource.AbstractDriverBasedDataSource.getConnection(AbstractDriverBasedDataSource.java:119) at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:46) at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446) ... 15 moreCaused by: oracle.net.ns.NetException: The Network Adapter could not establish the connection at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:328) at oracle.net.resolver.AddrResolution.resolveAndExecute(AddrResolution.java:421) at oracle.net.ns.NSProtocol.establishConnection(NSProtocol.java:630) at oracle.net.ns.NSProtocol.connect(NSProtocol.java:206) at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:966) at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:292) ... 27 moreCaused by: java.net.ConnectException: Connection refused at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351) at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366) at java.net.Socket.connect(Socket.java:529) at java.net.Socket.connect(Socket.java:478) at java.net.Socket.<init>(Socket.java:375) at java.net.Socket.<init>(Socket.java:189) at oracle.net.nt.TcpNTAdapter.connect(TcpNTAdapter.java:127) at oracle.net.nt.ConnOption.connect(ConnOption.java:126) at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:306) ... 32 moreDepois de varias horas debugando, descobrimos que esse erro foi causado por um erro na edicao do database.properties, na string de conexao com a base.A propriedade