i have a folder named jpa on windows xp desktop which contain two java files folder lib that has hibernate 4 required jars and the last is folder META-INF that contain persistence.xml
when i run the code i doesnt show me data table
java -cp .;./lib* mainjpa
Code:
mars 08, 2012 12:19:20 AM org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
mars 08, 2012 12:19:20 AM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.1.0.Final}
mars 08, 2012 12:19:20 AM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
mars 08, 2012 12:19:20 AM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
mars 08, 2012 12:19:24 AM org.hibernate.service.jdbc.connections.internal.Driver
ManagerConnectionProviderImpl configure
INFO: HHH000402: Using Hibernate built-in connection pool (not for production us
e!)
mars 08, 2012 12:19:24 AM org.hibernate.service.jdbc.connections.internal.Driver
ManagerConnectionProviderImpl configure
INFO: HHH000115: Hibernate connection pool size: 20
mars 08, 2012 12:19:24 AM org.hibernate.service.jdbc.connections.internal.Driver
ManagerConnectionProviderImpl configure
INFO: HHH000006: Autocommit mode: true
mars 08, 2012 12:19:24 AM org.hibernate.service.jdbc.connections.internal.Driver
ManagerConnectionProviderImpl configure
INFO: HHH000401: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql://local
host:3306/base]
mars 08, 2012 12:19:24 AM org.hibernate.service.jdbc.connections.internal.Driver
ManagerConnectionProviderImpl configure
INFO: HHH000046: Connection properties: {user=root, password=****, autocommit=tr
ue, release_mode=auto}
mars 08, 2012 12:19:26 AM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
mars 08, 2012 12:19:26 AM org.hibernate.engine.transaction.internal.TransactionF
actoryInitiator initiateService
INFO: HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal
.jdbc.JdbcTransactionFactory
mars 08, 2012 12:19:26 AM org.hibernate.hql.internal.ast.ASTQueryTranslatorFacto
ry <init>
INFO: HHH000397: Using ASTQueryTranslatorFactory
mars 08, 2012 12:19:28 AM org.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: HHH000227: Running hbm2ddl schema export
mars 08, 2012 12:19:29 AM org.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: HHH000230: Schema export complete
mainjpa.java
Code:
import javax.persistence.*;
import java.util.*;
import java.util.Iterator;
public class mainjpa {
public static void main(String arg[]){
EntityManagerFactory emf=Persistence.createEntityManagerFactory("test");
EntityManager em=emf.createEntityManager();
try{
EntityTransaction entr=em.getTransaction();
entr.begin();
Query query=em.createQuery("SELECT t FROM testent t");
List stList=query.getResultList();
Iterator stIterator=stList.iterator();
while(stIterator.hasNext()){
testent t=(testent)stIterator.next();
System.out.println(t.getId()+" "+t.getT()+" "+t.getTt());
}
entr.commit();
}
catch(Exception e){
System.out.println(e.getMessage());
}
finally{
em.close();
}
}
}