Hello,
I am using hibernate 2.1, oracle 8.1.7 and jdk 1.4. I have a raw data type in oracle table and used middlegen to generate the mapping documents and then hbm2java to generate the Java Classes. Middlegen mapped this raw(32) data type to byte[] which hibernate did not like so I changed it. However when I try to access records in this table, I get the following exception.
SEVERE: Could not execute query
java.sql.SQLException: Invalid column type
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java)
at oracle.jdbc.driver.OracleStatement.getLongValue(OracleStatement.java)
at oracle.jdbc.driver.OracleStatement.getByteValue(OracleStatement.java)
at oracle.jdbc.driver.OracleResultSetImpl.getByte(OracleResultSetImpl.ja
va)
at oracle.jdbc.driver.OracleResultSet.getByte(OracleResultSet.java)
at org.apache.commons.dbcp.DelegatingResultSet.getByte(DelegatingResultS
et.java:218)
at net.sf.hibernate.type.ByteType.get(ByteType.java:18)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:53)
at net.sf.hibernate.type.ManyToOneType.hydrate(ManyToOneType.java:60)
at net.sf.hibernate.type.EntityType.nullSafeGet(EntityType.java:154)
at net.sf.hibernate.impl.IteratorImpl.postNext(IteratorImpl.java:71)
at net.sf.hibernate.impl.IteratorImpl.<init>(IteratorImpl.java:48)
at net.sf.hibernate.hql.QueryTranslator.iterate(QueryTranslator.java:849
)
at net.sf.hibernate.impl.SessionImpl.iterate(SessionImpl.java:1577)
at net.sf.hibernate.impl.QueryImpl.iterate(QueryImpl.java:27)
at com.sbc.hrtech.framework.utility.InitializerPlugin.init(InitializerPl
ugin.java:106)
at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServle
t.java:1158)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:473)
at javax.servlet.GenericServlet.init(GenericServlet.java:256)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.
java:1044)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:88
7)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContex
t.java:3960)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4
283)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1125)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:832)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1125)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:518
)
at org.apache.catalina.core.StandardService.start(StandardService.java:5
19)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:234
5)
at org.apache.catalina.startup.Catalina.start(Catalina.java:598)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:297)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:398)
*****3*********************
******3********************
*******3*******************
********3******************
*********3*****************
net.sf.hibernate.JDBCException: Could not execute query
at net.sf.hibernate.impl.SessionImpl.iterate(SessionImpl.java:1580)
at net.sf.hibernate.impl.QueryImpl.iterate(QueryImpl.java:27)
at com.sbc.hrtech.framework.utility.InitializerPlugin.init(InitializerPl
ugin.java:106)
at org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServle
t.java:1158)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:473)
at javax.servlet.GenericServlet.init(GenericServlet.java:256)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.
java:1044)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:88
7)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContex
t.java:3960)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4
283)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1125)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:832)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1125)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:518
)
at org.apache.catalina.core.StandardService.start(StandardService.java:5
19)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:234
5)
at org.apache.catalina.startup.Catalina.start(Catalina.java:598)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:297)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:398)
Caused by: java.sql.SQLException: Invalid column type
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java)
at oracle.jdbc.driver.OracleStatement.getLongValue(OracleStatement.java)
at oracle.jdbc.driver.OracleStatement.getByteValue(OracleStatement.java)
at oracle.jdbc.driver.OracleResultSetImpl.getByte(OracleResultSetImpl.ja
va)
at oracle.jdbc.driver.OracleResultSet.getByte(OracleResultSet.java)
at org.apache.commons.dbcp.DelegatingResultSet.getByte(DelegatingResultS
et.java:218)
at net.sf.hibernate.type.ByteType.get(ByteType.java:18)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:62)
at net.sf.hibernate.type.NullableType.nullSafeGet(NullableType.java:53)
at net.sf.hibernate.type.ManyToOneType.hydrate(ManyToOneType.java:60)
at net.sf.hibernate.type.EntityType.nullSafeGet(EntityType.java:154)
at net.sf.hibernate.impl.IteratorImpl.postNext(IteratorImpl.java:71)
at net.sf.hibernate.impl.IteratorImpl.<init>(IteratorImpl.java:48)
at net.sf.hibernate.hql.QueryTranslator.iterate(QueryTranslator.java:849
)
at net.sf.hibernate.impl.SessionImpl.iterate(SessionImpl.java:1577)
... 22 more
Excpetion in InitializerPlugin
Apr 10, 2004 6:17:02 PM org.apache.catalina.core.StandardHost getDeployer
My java code is as follows:
SessionFactory sessionFactory = (SessionFactory)sc.getAttribute("LOA");
//new Configuration().configure().buildSessionFactory();
session = sessionFactory.openSession();
Transaction tx= session.beginTransaction();
Query query = session.createQuery("select loatype from LoaType as loatype where loatype.name = :name");
//query.setBinary("id",new String("D733604207895E06E0340800209BAAFF").getBytes());
query.setString("name","CCO Administrative (for PDL)");
System.out.println("**************1************");
System.out.println("***************1***********");
System.out.println("****************1**********");
System.out.println("*****************1*********");
System.out.println("******************1********");
for (Iterator it = query.iterate(); it.hasNext();) {
LoaType cat = (LoaType) it.next();
System.out.println("FIRST" + cat.getName() );
}
tx.commit();
session.close();
and my mapping document generated by middlegen and modified by me is as follows
<class name="com.sbc.hrtech.loa.server.hibernate.LoaType" table="LOA_TYPE">
<id name="id" type="byte" column="ID">
<generator class="assigned"/>
</id>
..............
..........
.........
What do I change the data type from byte to allow hibernate to work. In the database the type is raw(32)
Thanks,
Sohil
|