These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: AutoNumber+session.find
PostPosted: Sat Sep 10, 2005 6:47 am 
Newbie

Joined: Wed Jun 15, 2005 9:49 am
Posts: 12
hi all,

I'm using MS Access XP as a DB with struts and using Hibernate and I have an id feild (pk) "AutoNumber".
what is the compatible type with "AutoNumber". I used Long or long but the error in session.find is:

Caused by: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]Optional feature not implemented
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6879)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7036)
at sun.jdbc.odbc.JdbcOdbc.SQLBindInParameterBigint(JdbcOdbc.java:1179)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.setLong(JdbcOdbcPreparedStatement.java:592)
at net.sf.hibernate.type.LongType.set(LongType.java:35)
at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:48)
at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:35)
at net.sf.hibernate.loader.Loader.bindPositionalParameters(Loader.java:753)
at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:793)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:269)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:138)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:941)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:961)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:59)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:51)
at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:413)
... 59 more

thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 12, 2005 3:27 am 
Beginner
Beginner

Joined: Mon Apr 12, 2004 6:33 pm
Posts: 35
Dit you try Integer? An integer in java is wider than an integer in access.

_________________
Kees de Kooter

(don't hesitate to rate ;)


Top
 Profile  
 
 Post subject: AutoNumber+session.find
PostPosted: Tue Sep 13, 2005 4:33 am 
Newbie

Joined: Wed Jun 15, 2005 9:49 am
Posts: 12
hi all,
thanks kdekooter,

I chaned Autonumber to Number , but I couldn't solve it.

I found something strange about this problem, I wrote tow methods to load a user, getUser(username) returns user with spcified username and load by customer_id correctly but getUser_2() makes error:

customer_id is Autonumber in MS Access, and Long in User.java


----------x.jsp------
User user = UserService.getInstance().getUser(username); // correct

User user2 = UserService.getInstance().getUser_2(); //error


------error:
java.lang.RuntimeException: net.sf.hibernate.exception.GenericJDBCException: could not load: [general.User#2]
at general.UserService.getUser_2(UserService.java:351)
at org.apache.jsp.app_0005fdetails$jsp._jspService(app_0005fdetails$jsp.java:98)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
...


java.lang.RuntimeException: net.sf.hibernate.exception.GenericJDBCException: could not load: [general.User#2]
at general.UserService.getUser_2(UserService.java:351)
at org.apache.jsp.app_0005fdetails$jsp._jspService(app_0005fdetails$jsp.java:98)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
...

Caused by: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]Optional feature not implemented
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6879)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7036)
at sun.jdbc.odbc.JdbcOdbc.SQLBindInParameterBigint(JdbcOdbc.java:1179)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.setLong(JdbcOdbcPreparedStatement.java:592)
at net.sf.hibernate.type.LongType.set(LongType.java:35)
at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:48)
at net.sf.hibernate.type.NullableType.nullSafeSet(NullableType.java:35)
at net.sf.hibernate.loader.Loader.bindPositionalParameters(Loader.java:753)
at net.sf.hibernate.loader.Loader.prepareQueryStatement(Loader.java:793)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:269)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:138)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:941)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:961)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:59)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:51)
at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:413)
... 61 more

---

public User getUser(String username)
{

Session session = ConnectionFactory.getInstance().getSession();

try
{
List u = session.find("from general.User u where u.userName = ?", username, Hibernate.STRING);

Long id=((User) (u.get(0))).getCustomer_id () ;

return (User) session.load(User.class, id);
}

catch (ObjectNotFoundException onfe)
{
return null;
}
catch (HibernateException e)
{
System.err.println("Hibernate Exception" + e.getMessage());
throw new RuntimeException(e);
}

finally
{
if (session != null)
{
try
{
session.close();
}
catch (HibernateException e)
{
System.err.println("Hibernate Exception" + e.getMessage());
throw new RuntimeException(e);
}

}
}

}

-----------
public User getUser_2()
{


Session session = ConnectionFactory.getInstance().getSession();
try
{

Long id=new Long(2);
return (User) session.load(User.class, id);


}

catch (ObjectNotFoundException onfe)
{
return null;
}
catch (HibernateException e)
{

System.err.println("Hibernate Exception" + e.getMessage());
throw new RuntimeException(e);
}

finally
{
if (session != null)
{
try
{
session.close();
}
catch (HibernateException e)
{
System.err.println("Hibernate Exception" + e.getMessage());
throw new RuntimeException(e);
}

}
}

}


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 13, 2005 5:02 am 
Beginner
Beginner

Joined: Mon Apr 12, 2004 6:33 pm
Posts: 35
I am afraid you have hit the limits of the Jdbc-Odbc bridge. You could try a JDBC drver for Access like the one of aveconect: http://www.aveconnect.com/jdbc-driver-MS-Access-2.htm

_________________
Kees de Kooter

(don't hesitate to rate ;)


Top
 Profile  
 
 Post subject: load+Number(Integer)+child+parent
PostPosted: Sat Sep 17, 2005 8:12 am 
Newbie

Joined: Wed Jun 15, 2005 9:49 am
Posts: 12
hi kdekooter,

thanks for the url, I tried useing aveconnect 2.0 server, and it makes message "Evaluation period over" when I restart Atinav Access server component.
but without aveconnect, I used getProduct() which P.K is Number(Integer) in Access, and it works correctly.
I tried to use "public Quantity getQuantity()" like that with P.K Number(Integer) but it makes error, and I think maybe it's because of product is parrent (1->n) and Quantity is child (n->1), I'm not sure could you help about this problem.

thanks.
--------------------------------

public Product getProduct()
{


Session session = ConnectionFactory.getInstance().getSession();
try
{


Integer id=new Integer(1);
return (Product) session.load(Product.class, id);
}

catch (ObjectNotFoundException onfe)
{
return null;
}
catch (HibernateException e)
{

System.err.println("Hibernate Exception" + e.getMessage());
throw new RuntimeException(e);
}

finally
{
if (session != null)
{
try
{
session.close();
}
catch (HibernateException e)
{
System.err.println("Hibernate Exception" + e.getMessage());
throw new RuntimeException(e);
}

}
}

}
------------------
java.lang.RuntimeException: net.sf.hibernate.exception.SQLGrammarException: could not load: [general.Quantity#1]
at general.UserService.getQuantity(UserService.java:850)
at org.apache.jsp.app_0005fdetails$jsp._jspService(app_0005fdetails$jsp.java:102)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:201)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:381)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473)
....
Caused by: net.sf.hibernate.exception.SQLGrammarException: could not load: [general.Quantity#1]
at net.sf.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:58)
at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29)
at net.sf.hibernate.persister.AbstractEntityPersister.convert(AbstractEntityPersister.java:1331)
at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:416)
at net.sf.hibernate.impl.SessionImpl.doLoad(SessionImpl.java:2131)
at net.sf.hibernate.impl.SessionImpl.doLoadByClass(SessionImpl.java:2001)
at net.sf.hibernate.impl.SessionImpl.load(SessionImpl.java:1930)
at general.UserService.getQuantity(UserService.java:838)
... 57 more
Caused by: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'quantity0_.customer_id=user1_.customer_id left outer join app_product product2_ on quantity0_.product_id=product2_.product_id'.
at sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6879)
at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7036)
at sun.jdbc.odbc.JdbcOdbc.SQLExecute(JdbcOdbc.java:3104)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.execute(JdbcOdbcPreparedStatement.java:214)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeQuery(JdbcOdbcPreparedStatement.java:89)
at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:89)
at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:880)
at net.sf.hibernate.loader.Loader.doQuery(Loader.java:273)
at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:138)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:941)
at net.sf.hibernate.loader.Loader.loadEntity(Loader.java:961)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:59)
at net.sf.hibernate.loader.EntityLoader.load(EntityLoader.java:51)
at net.sf.hibernate.persister.EntityPersister.load(EntityPersister.java:413)
... 61 more
________________________________________-


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.