O metodo save do Hibernate não inclui o registro

10 respostas
G

Olá, sou ex aluno da caelum, e estou com duvidas que nao estou conseguindo resolver.

Pois é pessoal, ao rodar o método salva do Dao não apresenta erro algum mas tambem nao inclui nada. Caso eu recupere pelo método procura, um registro incluido diretamente so banco ele traz o objeto sem problemas.
O banco é postgree, java(eclipse).

abaixo segue a implementação:

public static void main(String[] args) {

// TODO Auto-generated method stub		

Lote test = new Lote();
test.setDt("outro bata ");
	Session session = new HibernateUtil().getSession();
	LoteDao daoLote = new LoteDao(session);
	daoLote.Salva(test);
	//System.out.println(test.getId() );  
	//test = daoLote.procura(10L);
	
	System.out.println(test.getDt() );
	System.out.println(test.getId() );
	session.close();
	
}
public class LoteDao {

private Session session;

public LoteDao(Session session){

this.session = session;

}

public void Salva (Lote lt){

this.session.save(lt);

}
public Lote procura(Long id){
		return (Lote) this.session.load(Lote.class, id);
	
}

}

@Entity
public class Lote {

@Id
@GeneratedValue
private Long Id;
private String dt;

public String getDt() {
	return dt;
}
public void setDt(String dataAtualDate) {
	this.dt = dataAtualDate;
}
public Long getId() {
	return Id;
}
public void setId(Long id) {
	this.Id = id;
}

}

Desde de ja agradeço.

abaixo segue o spool gerado pelo hibernate:

16:03:10,039  INFO Version:15 - Hibernate Annotations 3.2.0.GA

16:03:10,054  INFO Environment:500 - Hibernate 3.2.0

16:03:10,054  INFO Environment:518 - loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=org.postgresql.Driver, hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect, hibernate.format_sql=true, hibernate.connection.username=postgres, hibernate.hbm2ddl.auto=create;  , hibernate.connection.url=jdbc:postgresql://localhost:5432/scjp, hibernate.bytecode.use_reflection_optimizer=false, hibernate.show_sql=true, hibernate.connection.password=****}

16:03:10,054  INFO Environment:667 - Bytecode provider name : cglib

16:03:10,070  INFO Environment:584 - using JDK 1.4 java.sql.Timestamp handling

16:03:10,164 DEBUG Configuration:1209 - Preparing to build session factory with filters : {}

16:03:10,164 DEBUG AnnotationConfiguration:235 - Execute first pass mapping processing

16:03:10,226 DEBUG AnnotationConfiguration:435 - Process hbm files

16:03:10,226 DEBUG AnnotationConfiguration:443 - Process annotated classes

16:03:10,226  INFO AnnotationBinder:387 - Binding entity from annotated class: br.raisdosabor.modelo.Lote

16:03:10,242 DEBUG Ejb3Column:161 - Binding column DTYPE unique false

16:03:10,258 DEBUG EntityBinder:212 - Import with entity name=Lote

16:03:10,273  INFO EntityBinder:340 - Bind entity br.raisdosabor.modelo.Lote on table Lote

16:03:10,273 DEBUG AnnotationBinder:940 - Processing br.raisdosabor.modelo.Lote property annotation

16:03:10,289 DEBUG AnnotationBinder:940 - Processing br.raisdosabor.modelo.Lote field annotation

16:03:10,289 DEBUG AnnotationBinder:1032 - Processing annotations of br.raisdosabor.modelo.Lote.Id

16:03:10,289 DEBUG Ejb3Column:161 - Binding column Id unique false

16:03:10,289 DEBUG AnnotationBinder:1153 - Id is an id

16:03:10,304 DEBUG SimpleValueBinder:220 - building SimpleValue for Id

16:03:10,304 DEBUG PropertyBinder:122 - Building property Id

16:03:10,304 DEBUG PropertyBinder:155 - Cascading Id with null

16:03:10,304 DEBUG AnnotationBinder:1186 - Bind @Id on Id

16:03:10,304 DEBUG AnnotationBinder:1032 - Processing annotations of br.raisdosabor.modelo.Lote.dt

16:03:10,304 DEBUG Ejb3Column:161 - Binding column dt unique false

16:03:10,304 DEBUG PropertyBinder:102 - binding property dt with lazy=false

16:03:10,304 DEBUG SimpleValueBinder:220 - building SimpleValue for dt

16:03:10,304 DEBUG PropertyBinder:122 - Building property dt

16:03:10,304 DEBUG PropertyBinder:155 - Cascading dt with null

16:03:10,320 DEBUG AnnotationConfiguration:329 - processing manytoone fk mappings

16:03:10,320 DEBUG Configuration:1044 - processing extends queue

16:03:10,320 DEBUG Configuration:1048 - processing collection mappings

16:03:10,320 DEBUG Configuration:1059 - processing native query and ResultSetMapping mappings

16:03:10,320 DEBUG Configuration:1067 - processing association property references

16:03:10,320 DEBUG Configuration:1089 - processing foreign key constraints

16:03:10,336 DEBUG ClassValidator:160 - ResourceBundle ValidatorMessages not found in thread context classloader

16:03:10,336 DEBUG ClassValidator:170 - ResourceBundle ValidatorMessages not found in Validator classloader. Delegate to org.hibernate.validator.resources.DefaultValidatorMessages

16:03:10,398  INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)

16:03:10,398  INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 20

16:03:10,398  INFO DriverManagerConnectionProvider:45 - autocommit mode: false

16:03:10,414  INFO DriverManagerConnectionProvider:80 - using driver: org.postgresql.Driver at URL: jdbc:postgresql://localhost:5432/scjp

16:03:10,414  INFO DriverManagerConnectionProvider:83 - connection properties: {user=postgres, password=krishna}

16:03:10,414 DEBUG DriverManagerConnectionProvider:93 - total checked-out connections: 0

16:03:10,414 DEBUG DriverManagerConnectionProvider:109 - opening new JDBC connection

16:03:10,570 DEBUG DriverManagerConnectionProvider:115 - created connection to: jdbc:postgresql://localhost:5432/scjp, Isolation Level: 2

16:03:10,570  INFO SettingsFactory:81 - RDBMS: PostgreSQL, version: 9.0.4

16:03:10,570  INFO SettingsFactory:82 - JDBC driver: PostgreSQL Native Driver, version: PostgreSQL 9.0 JDBC3 (build 801)

16:03:10,586 DEBUG DriverManagerConnectionProvider:129 - returning connection to pool, pool size: 1

16:03:10,586  INFO Dialect:141 - Using dialect: org.hibernate.dialect.PostgreSQLDialect

16:03:10,601  INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions)

16:03:10,601  INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)

16:03:10,601  INFO SettingsFactory:134 - Automatic flush during beforeCompletion(): disabled

16:03:10,601  INFO SettingsFactory:138 - Automatic session close at end of transaction: disabled

16:03:10,601  INFO SettingsFactory:145 - JDBC batch size: 15

16:03:10,601  INFO SettingsFactory:148 - JDBC batch updates for versioned data: disabled

16:03:10,601  INFO SettingsFactory:153 - Scrollable result sets: enabled

16:03:10,601 DEBUG SettingsFactory:157 - Wrap result sets: disabled

16:03:10,601  INFO SettingsFactory:161 - JDBC3 getGeneratedKeys(): enabled

16:03:10,601  INFO SettingsFactory:169 - Connection release mode: auto

16:03:10,601  INFO SettingsFactory:196 - Default batch fetch size: 1

16:03:10,601  INFO SettingsFactory:200 - Generate SQL with comments: disabled

16:03:10,601  INFO SettingsFactory:204 - Order SQL updates by primary key: disabled

16:03:10,601  INFO SettingsFactory:369 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory

16:03:10,601  INFO ASTQueryTranslatorFactory:24 - Using ASTQueryTranslatorFactory

16:03:10,601  INFO SettingsFactory:212 - Query language substitutions: {}

16:03:10,601  INFO SettingsFactory:217 - JPA-QL strict compliance: disabled

16:03:10,617  INFO SettingsFactory:222 - Second-level cache: enabled

16:03:10,617  INFO SettingsFactory:226 - Query cache: disabled

16:03:10,617  INFO SettingsFactory:356 - Cache provider: org.hibernate.cache.NoCacheProvider

16:03:10,617  INFO SettingsFactory:241 - Optimize cache for minimal puts: disabled

16:03:10,617  INFO SettingsFactory:250 - Structured second-level cache entries: disabled

16:03:10,617 DEBUG SQLExceptionConverterFactory:52 - Using dialect defined converter

16:03:10,617  INFO SettingsFactory:270 - Echoing all SQL to stdout

16:03:10,617  INFO SettingsFactory:277 - Statistics: disabled

16:03:10,617  INFO SettingsFactory:281 - Deleted entity synthetic identifier rollback: disabled

16:03:10,617  INFO SettingsFactory:296 - Default entity-mode: pojo

16:03:10,648  INFO SessionFactoryImpl:161 - building session factory

16:03:10,648 DEBUG SessionFactoryImpl:173 - Session factory constructed with filter configurations : {}

16:03:10,648 DEBUG SessionFactoryImpl:177 - instantiating session factory with properties: {java.runtime.name=Java SE Runtime Environment, hibernate.connection.password=krishna, sun.boot.library.path=C:\Arquivos de programas\Java\jre6\bin, java.vm.version=11.2-b01, hibernate.connection.username=postgres, java.vm.vendor=Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=;, java.vm.name=Java HotSpot™ Client VM, <a href="http://file.encoding.pkg=sun.io">file.encoding.pkg=sun.io</a>, user.country=BR, sun.java.launcher=SUN_STANDARD, sun.os.patch.level=Service Pack 3, java.vm.specification.name=Java Virtual Machine Specification, user.dir=C:\Raiz Teste Banco\jdbc, java.runtime.version=1.6.0_12-b04, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.endorsed.dirs=C:\Arquivos de programas\Java\jre6\lib\endorsed, os.arch=x86, java.io.tmpdir=C:\DOCUME~1\041137~1\CONFIG~1\Temp, line.separator=

, java.vm.specification.vendor=Sun Microsystems Inc., user.variant=, os.name=Windows XP, sun.jnu.encoding=Cp1252, java.library.path=C:\Arquivos de programas\Java\jre6\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Arquivos de programas/Java/jre6/bin/client;C:/Arquivos de programas/Java/jre6/bin;C:\oraclexe\app\oracle\product\10.2.0\server\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\Arquivos de programas\Microsoft SQL Server\100\Tools\Binn;c:\Arquivos de programas\Microsoft SQL Server\100\DTS\Binn;C:\WINDOWS\system32\WindowsPowerShell\v1.0;c:\Arquivos de programas\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE;C:\WINDOWS\<a href="http://Microsoft.NET">Microsoft.NET</a>\Framework\v2.0.50727;c:\Arquivos de programas\Microsoft SQL Server\90\Tools\binn;C:\Arquivos de programas\Java\jdk1.6.0_12\bin;C:\WINDOWS\system32\WindowsPowerShell\v1.0;C:\Arquivos de programas\Windows Imaging, java.specification.name=Java Platform API Specification, java.class.version=50.0, sun.management.compiler=HotSpot Client Compiler, os.version=5.1, user.home=C:\Documents and Settings\041137777, user.timezone=America/Sao_Paulo, java.awt.printerjob=sun.awt.windows.WPrinterJob, file.encoding=Cp1252, java.specification.version=1.6, hibernate.format_sql=true, hibernate.connection.driver_class=org.postgresql.Driver, user.name=041137777, java.class.path=C:\Raiz Teste Banco\jdbc\bin;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2.0.ga.tar.gz;C:\Raiz Teste Banco\jdbc\lib\hibernate-annotations-3.2.0.GA.tar.gz;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\ant-1.6.5.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\ant-antlr-1.6.5.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\ant-junit-1.6.5.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\ant-launcher-1.6.5.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\ant-swing-1.6.5.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\antlr-2.7.6.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\asm-attrs.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\asm.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\c3p0-0.9.0.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\cglib-2.1.3.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\checkstyle-all.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\cleanimports.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\commons-collections-2.1.1.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\commons-logging-1.0.4.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\concurrent-1.3.2.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\connector.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\dom4j-1.6.1.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\ehcache-1.2.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\jaas.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\jacc-1_0-fr.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\javassist.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\jaxen-1.1-beta-7.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\jboss-cache.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\jboss-common.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\jboss-jmx.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\jboss-system.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\jdbc2_0-stdext.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\jgroups-2.2.8.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\jta.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\junit-3.8.1.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\log4j-1.2.11.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\oscache-2.1.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\proxool-0.8.3.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\swarmcache-1.0rc2.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\syndiag2.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\versioncheck.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\xerces-2.6.2.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\lib\xml-apis.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-3.2\hibernate3.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-annotations-3.2.0.GA\lib\ejb3-persistence.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-annotations-3.2.0.GA\lib\lucene-core-2.0.0.jar;C:\Raiz Teste Banco\jdbc\lib\hibernate-annotations-3.2.0.GA\hibernate-annotations.jar;C:\Raiz Teste Banco\jdbc\lib\postgresql-9.0-801.jdbc3.zip, hibernate.bytecode.use_reflection_optimizer=false, hibernate.show_sql=true, java.vm.specification.version=1.0, sun.arch.data.model=32, java.home=C:\Arquivos de programas\Java\jre6, hibernate.connection.url=jdbc:postgresql://localhost:5432/scjp, hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect, java.specification.vendor=Sun Microsystems Inc., user.language=pt, awt.toolkit=sun.awt.windows.WToolkit, java.vm.info=mixed mode, sharing, java.version=1.6.0_12, java.ext.dirs=C:\Arquivos de programas\Java\jre6\lib\ext;C:\WINDOWS\Sun\Java\lib\ext, sun.boot.class.path=C:\Arquivos de programas\Java\jre6\lib\resources.jar;C:\Arquivos de programas\Java\jre6\lib\rt.jar;C:\Arquivos de programas\Java\jre6\lib\sunrsasign.jar;C:\Arquivos de programas\Java\jre6\lib\jsse.jar;C:\Arquivos de programas\Java\jre6\lib\jce.jar;C:\Arquivos de programas\Java\jre6\lib\charsets.jar;C:\Arquivos de programas\Java\jre6\classes, java.vendor=Sun Microsystems Inc., file.separator=, java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport.cgi, hibernate.hbm2ddl.auto=create;  , sun.cpu.endian=little, sun.io.unicode.encoding=UnicodeLittle, sun.desktop=windows, sun.cpu.isalist=}

16:03:10,867 DEBUG AbstractEntityPersister:2673 - Static SQL for entity: br.raisdosabor.modelo.Lote

16:03:10,867 DEBUG AbstractEntityPersister:2678 -  Version select: select Id from Lote where Id =?

16:03:10,867 DEBUG AbstractEntityPersister:2681 -  Snapshot select: select lote_.Id, lote_.dt as dt0_ from Lote lote_ where lote_.Id=?

16:03:10,867 DEBUG AbstractEntityPersister:2684 -  Insert 0: insert into Lote (dt, Id) values (?, ?)

16:03:10,867 DEBUG AbstractEntityPersister:2685 -  Update 0: update Lote set dt=? where Id=?

16:03:10,867 DEBUG AbstractEntityPersister:2686 -  Delete 0: delete from Lote where Id=?

16:03:10,898 DEBUG EntityLoader:79 - Static select for entity br.raisdosabor.modelo.Lote: select lote0_.Id as Id0_0_, lote0_.dt as dt0_0_ from Lote lote0_ where lote0_.Id=?

16:03:10,898 DEBUG EntityLoader:79 - Static select for entity br.raisdosabor.modelo.Lote: select lote0_.Id as Id0_0_, lote0_.dt as dt0_0_ from Lote lote0_ where lote0_.Id=?

16:03:10,898 DEBUG EntityLoader:79 - Static select for entity br.raisdosabor.modelo.Lote: select lote0_.Id as Id0_0_, lote0_.dt as dt0_0_ from Lote lote0_ where lote0_.Id=? for update

16:03:10,898 DEBUG EntityLoader:79 - Static select for entity br.raisdosabor.modelo.Lote: select lote0_.Id as Id0_0_, lote0_.dt as dt0_0_ from Lote lote0_ where lote0_.Id=? for update

16:03:10,898 DEBUG EntityLoader:79 - Static select for entity br.raisdosabor.modelo.Lote: select lote0_.Id as Id0_0_, lote0_.dt as dt0_0_ from Lote lote0_ where lote0_.Id=? for update

16:03:10,898 DEBUG EntityLoader:34 - Static select for action ACTION_MERGE on entity br.raisdosabor.modelo.Lote: select lote0_.Id as Id0_0_, lote0_.dt as dt0_0_ from Lote lote0_ where lote0_.Id=?

16:03:10,898 DEBUG EntityLoader:34 - Static select for action ACTION_REFRESH on entity br.raisdosabor.modelo.Lote: select lote0_.Id as Id0_0_, lote0_.dt as dt0_0_ from Lote lote0_ where lote0_.Id=?

16:03:10,898 DEBUG SessionFactoryObjectFactory:39 - initializing class SessionFactoryObjectFactory

16:03:10,898 DEBUG SessionFactoryObjectFactory:76 - registered: 2c9e0ba733897f710133897f72b20000 (unnamed)

16:03:10,898  INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured

16:03:10,898 DEBUG SessionFactoryImpl:308 - instantiated session factory

16:03:10,914 DEBUG SessionFactoryImpl:390 - Checking 0 named HQL queries

16:03:10,914 DEBUG SessionFactoryImpl:410 - Checking 0 named SQL queries

16:03:10,945 DEBUG SessionImpl:220 - opened session at timestamp: [telefone removido]

16:03:10,945 DEBUG DefaultSaveOrUpdateEventListener:161 - saving transient instance

16:03:10,945 DEBUG AbstractBatcher:358 - about to open PreparedStatement (open PreparedStatements: 0, globally: 0)

16:03:10,945 DEBUG ConnectionManager:415 - opening JDBC connection

16:03:10,945 DEBUG DriverManagerConnectionProvider:93 - total checked-out connections: 0

16:03:10,945 DEBUG DriverManagerConnectionProvider:99 - using pooled JDBC connection, pool size: 0

16:03:10,961 DEBUG SQL:393 -

select

nextval (hibernate_sequence)

Hibernate:

select

nextval (hibernate_sequence)

16:03:10,961 DEBUG AbstractBatcher:476 - preparing statement

16:03:10,961 DEBUG SequenceGenerator:82 - Sequence identifier generated: 2

16:03:10,961 DEBUG AbstractBatcher:366 - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)

16:03:10,961 DEBUG AbstractBatcher:525 - closing statement

16:03:10,961 DEBUG AbstractSaveEventListener:113 - generated identifier: 2, using strategy: org.hibernate.id.SequenceGenerator

16:03:10,961 DEBUG AbstractSaveEventListener:152 - saving [br.raisdosabor.modelo.Lote#2]

outro bata

2

16:03:10,976 DEBUG SessionImpl:273 - closing session

16:03:10,976 DEBUG ConnectionManager:374 - performing cleanup

16:03:10,976 DEBUG ConnectionManager:435 - releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]

16:03:10,976 DEBUG DriverManagerConnectionProvider:129 - returning connection to pool, pool size: 1

16:03:10,976 DEBUG JDBCContext:215 - after transaction completion

16:03:10,976 DEBUG ConnectionManager:398 - aggressively releasing JDBC connection

16:03:10,976 DEBUG SessionImpl:422 - after transaction completion

10 Respostas

Hebert_Coelho

Tenta fazer um session.commit() antes do close.

A

cara,

primeiro, qdo vc for postar algum codigo, coloque dentro da tag [code].

vc tem inicar uma transacao, salvar e depois comitar, caso de algum erro rollback.

t+

G

Obrigado pelas repostas, porem nao surtiram efeitos
Na session não existe o metodo commit(), mesmo utilizando o metodo session.beginTransaction() não insere. Em relação a tag [code] nao ví nenhuma orientação para isso seria
Grato.

drsmachado
Gustavo Rios:
Obrigado pelas repostas, porem nao surtiram efeitos Na session não existe o metodo commit(), mesmo utilizando o metodo session.beginTransaction() não insere. Em relação a tag [code] nao ví nenhuma orientação para isso seria Grato.
Se não leu nenhuma instrução, deveria procurar no fórum de java básico e nas regras do fórum. Segundo, o método commit não pertence ao objeto da interface Session, mas ao objeto de Transaction.

Releia o livro ou a apostila e tenta ver onde errou.

Ah, posts sem formatação afastam respostas adequadas.

G

Olá pela apostila que estou lendo FJ-21 o codigo de exemplos e os textos explicativos não fazem menção ao objeto de transação como pode ser verificado no Capitulo 16. Mas realmente deu resultado, sobre formatação de codigo vou porcurar me informar melhor.
Grato.

L

Tenta assim:

LoteDao { public void salvar(Lote lote) { Session session = ...; // Pega sua sessão Transaction transaction = session.getTransaction(); transaction.begin(); session.save(lote); transaction.commit(); session.flush(); session.close(); } }

A

cara,

vc tem que fazer isso.

Transaction transaction = session.beginTransaction();
		transaction.begin();
		session.save();
		transaction.commit();

t+

G

Vlw Bicho ja rolou,
Obrigado pela atenção.
Eu tenho que encerrar o tópico?

formatarei assim da proxima vez 
Gratidão total.
A

sim,

basta editar o titulo do seu post e colocar [RESOLVIDO]

t+

G

Vlw

Criado 9 de novembro de 2011
Ultima resposta 9 de nov. de 2011
Respostas 10
Participantes 5