Hi all,
i am just restarting with java and i have an issue with this function in the APP.java i found this code on many examples on internet but for me is not working can someone help me find out what i am making wrog here :). PLEASE:=(:
private static void read_D() {
SessionFactory sf = HibernateUtil.getSessionFactory();
Session session = sf.openSession();
List list = session.createQuery("select employee_data.id, employee_data.datelindja, employee_data.muaji, employee_data.shenja_horoskopit from Employee_Data as employee_data where employee_data.datelindja is '24'and employee_data.viti is '1981' and employee_data.muaji is 'shtator' order by employee_data.id").list();
System.out.println("Records Found ____ :");
Iterator I = list.iterator();
while (I.hasNext()) {
Employee_Data emp = (Employee_Data) I.next();
System.out.print("ID e rreshtit :" + emp.getId() + "datelindja :" + emp.getDatelindja() + "Muaji :" + emp.getViti() + "Viti :" + emp.getViti());
}
session.close();
}
error is:
ic 10, 2014 11:39:47 AM org.hibernate.annotations.common.reflection.java.J avaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.4.Final}
dic 10, 2014 11:39:47 AM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.3.5.Final}
dic 10, 2014 11:39:47 AM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
dic 10, 2014 11:39:47 AM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
dic 10, 2014 11:39:47 AM org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
dic 10, 2014 11:39:47 AM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
dic 10, 2014 11:39:48 AM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
WARN: HHH000223: Recognized obsolete hibernate namespace Hibernate. Everything data. - Hibernate. Use namespace Directory listing /dtd - Hibernate instead. Refer to Hibernate 3.6 Migration Guide!
dic 10, 2014 11:39:48 AM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: tmp/Employee.hbm.xml
dic 10, 2014 11:39:48 AM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
WARN: HHH000223: Recognized obsolete hibernate namespace Hibernate. Everything data. - Hibernate. Use namespace Directory listing /dtd - Hibernate instead. Refer to Hibernate 3.6 Migration Guide!
dic 10, 2014 11:39:48 AM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: tmp/Employee_Data.hbm.xml
dic 10, 2014 11:39:48 AM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
WARN: HHH000223: Recognized obsolete hibernate namespace Hibernate. Everything data. - Hibernate. Use namespace Directory listing /dtd - Hibernate instead. Refer to Hibernate 3.6 Migration Guide!
dic 10, 2014 11:39:48 AM org.hibernate.cfg.Configuration doConfigure
INFO: HHH000041: Configured SessionFactory: null
dic 10, 2014 11:39:49 AM org.hibernate.engine.jdbc.connections.internal.Dri verManagerConnectionProviderImpl configure
WARN: HHH000402: Using Hibernate built-in connection pool (not for production use!)
dic 10, 2014 11:39:49 AM org.hibernate.engine.jdbc.connections.internal.Dri verManagerConnectionProviderImpl buildCreator
INFO: HHH000401: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql://192.168.10.240:3306/timitest1]
dic 10, 2014 11:39:49 AM org.hibernate.engine.jdbc.connections.internal.Dri verManagerConnectionProviderImpl buildCreator
INFO: HHH000046: Connection properties: {user=test, password=****}
dic 10, 2014 11:39:49 AM org.hibernate.engine.jdbc.connections.internal.Dri verManagerConnectionProviderImpl buildCreator
INFO: HHH000006: Autocommit mode: false
dic 10, 2014 11:39:49 AM org.hibernate.engine.jdbc.connections.internal.Dri verManagerConnectionProviderImpl configure
INFO: HHH000115: Hibernate connection pool size: 1 (min=1)
dic 10, 2014 11:39:51 AM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
dic 10, 2014 11:39:51 AM org.hibernate.engine.jdbc.internal.LobCreatorBuild er useContextualLobCreation
INFO: HHH000423: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4
dic 10, 2014 11:39:51 AM org.hibernate.engine.transaction.internal.Transact ionFactoryInitiator initiateService
INFO: HHH000399: Using default transaction strategy (direct JDBC transactions)
dic 10, 2014 11:39:51 AM org.hibernate.hql.internal.ast.ASTQueryTranslatorF actory <init>
INFO: HHH000397: Using ASTQueryTranslatorFactory
dic 10, 2014 11:39:52 AM org.hibernate.tool.hbm2ddl.SchemaValidator validate
INFO: HHH000229: Running schema validator
dic 10, 2014 11:39:52 AM org.hibernate.tool.hbm2ddl.SchemaValidator validate
INFO: HHH000102: Fetching database metadata
dic 10, 2014 11:39:53 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: HHH000261: Table found: timitest1.employee
dic 10, 2014 11:39:53 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: HHH000037: Columns: [cell_phone, id, birth_date, lastname, firstname]
dic 10, 2014 11:39:53 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: HHH000261: Table found: timitest1.employee_data
dic 10, 2014 11:39:53 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: HHH000037: Columns: [id, shenja_horoskopit, viti, muaji, datelindja]
Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to tmp.Employee_Data
at tmp.APP.read_D(APP.java:218)
at tmp.APP.main(APP.java:61)
Records Found ____ :
i am just restarting with java and i have an issue with this function in the APP.java i found this code on many examples on internet but for me is not working can someone help me find out what i am making wrog here :). PLEASE:=(:
private static void read_D() {
SessionFactory sf = HibernateUtil.getSessionFactory();
Session session = sf.openSession();
List list = session.createQuery("select employee_data.id, employee_data.datelindja, employee_data.muaji, employee_data.shenja_horoskopit from Employee_Data as employee_data where employee_data.datelindja is '24'and employee_data.viti is '1981' and employee_data.muaji is 'shtator' order by employee_data.id").list();
System.out.println("Records Found ____ :");
Iterator I = list.iterator();
while (I.hasNext()) {
Employee_Data emp = (Employee_Data) I.next();
System.out.print("ID e rreshtit :" + emp.getId() + "datelindja :" + emp.getDatelindja() + "Muaji :" + emp.getViti() + "Viti :" + emp.getViti());
}
session.close();
}
error is:
ic 10, 2014 11:39:47 AM org.hibernate.annotations.common.reflection.java.J avaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.4.Final}
dic 10, 2014 11:39:47 AM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.3.5.Final}
dic 10, 2014 11:39:47 AM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
dic 10, 2014 11:39:47 AM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
dic 10, 2014 11:39:47 AM org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
dic 10, 2014 11:39:47 AM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
dic 10, 2014 11:39:48 AM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
WARN: HHH000223: Recognized obsolete hibernate namespace Hibernate. Everything data. - Hibernate. Use namespace Directory listing /dtd - Hibernate instead. Refer to Hibernate 3.6 Migration Guide!
dic 10, 2014 11:39:48 AM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: tmp/Employee.hbm.xml
dic 10, 2014 11:39:48 AM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
WARN: HHH000223: Recognized obsolete hibernate namespace Hibernate. Everything data. - Hibernate. Use namespace Directory listing /dtd - Hibernate instead. Refer to Hibernate 3.6 Migration Guide!
dic 10, 2014 11:39:48 AM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: tmp/Employee_Data.hbm.xml
dic 10, 2014 11:39:48 AM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
WARN: HHH000223: Recognized obsolete hibernate namespace Hibernate. Everything data. - Hibernate. Use namespace Directory listing /dtd - Hibernate instead. Refer to Hibernate 3.6 Migration Guide!
dic 10, 2014 11:39:48 AM org.hibernate.cfg.Configuration doConfigure
INFO: HHH000041: Configured SessionFactory: null
dic 10, 2014 11:39:49 AM org.hibernate.engine.jdbc.connections.internal.Dri verManagerConnectionProviderImpl configure
WARN: HHH000402: Using Hibernate built-in connection pool (not for production use!)
dic 10, 2014 11:39:49 AM org.hibernate.engine.jdbc.connections.internal.Dri verManagerConnectionProviderImpl buildCreator
INFO: HHH000401: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql://192.168.10.240:3306/timitest1]
dic 10, 2014 11:39:49 AM org.hibernate.engine.jdbc.connections.internal.Dri verManagerConnectionProviderImpl buildCreator
INFO: HHH000046: Connection properties: {user=test, password=****}
dic 10, 2014 11:39:49 AM org.hibernate.engine.jdbc.connections.internal.Dri verManagerConnectionProviderImpl buildCreator
INFO: HHH000006: Autocommit mode: false
dic 10, 2014 11:39:49 AM org.hibernate.engine.jdbc.connections.internal.Dri verManagerConnectionProviderImpl configure
INFO: HHH000115: Hibernate connection pool size: 1 (min=1)
dic 10, 2014 11:39:51 AM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
dic 10, 2014 11:39:51 AM org.hibernate.engine.jdbc.internal.LobCreatorBuild er useContextualLobCreation
INFO: HHH000423: Disabling contextual LOB creation as JDBC driver reported JDBC version [3] less than 4
dic 10, 2014 11:39:51 AM org.hibernate.engine.transaction.internal.Transact ionFactoryInitiator initiateService
INFO: HHH000399: Using default transaction strategy (direct JDBC transactions)
dic 10, 2014 11:39:51 AM org.hibernate.hql.internal.ast.ASTQueryTranslatorF actory <init>
INFO: HHH000397: Using ASTQueryTranslatorFactory
dic 10, 2014 11:39:52 AM org.hibernate.tool.hbm2ddl.SchemaValidator validate
INFO: HHH000229: Running schema validator
dic 10, 2014 11:39:52 AM org.hibernate.tool.hbm2ddl.SchemaValidator validate
INFO: HHH000102: Fetching database metadata
dic 10, 2014 11:39:53 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: HHH000261: Table found: timitest1.employee
dic 10, 2014 11:39:53 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: HHH000037: Columns: [cell_phone, id, birth_date, lastname, firstname]
dic 10, 2014 11:39:53 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: HHH000261: Table found: timitest1.employee_data
dic 10, 2014 11:39:53 AM org.hibernate.tool.hbm2ddl.TableMetadata <init>
INFO: HHH000037: Columns: [id, shenja_horoskopit, viti, muaji, datelindja]
Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to tmp.Employee_Data
at tmp.APP.read_D(APP.java:218)
at tmp.APP.main(APP.java:61)
Records Found ____ :