Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
3.0.5:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="lyo.hotmail.domain">
<class
name="Author"
table="AUTHOR"
>
<id
name="authorId"
type="string"
column="AUTHOR_ID"
>
<generator class="uuid.hex"/>
</id>
<property
name="authorSex"
column="AUTHOR_SEX"
type="string"
not-null="false"
length="1"
/>
<property
name="authorMemo"
column="AUTHOR_MEMO"
type="string"
not-null="false"
length="19"
/>
<property
name="authorEmail"
column="AUTHOR_EMAIL"
type="string"
not-null="false"
length="100"
/>
<property
name="authorName"
column="AUTHOR_NAME"
type="string"
not-null="false"
length="40"
/>
<property
name="authorAge"
column="AUTHOR_AGE"
type="integer"
not-null="false"
length="11"
/>
<set
inverse="true"
lazy="true"
name="articleSet"
>
<key column="AUTHOR_ID" />
<one-to-many class="Article" />
</set>
</class>
</hibernate-mapping>
:
public List getAuthors() throws DataAccessException {
// TODO Auto-generated method stub
return this.getHibernateTemplate().find("from Author a");
}
2005-08-11 12:30:07,695 [main] INFO org.springframework.jdbc.support.SQLErrorCodesFactory - SQLErrorCodes loaded: [DB2, HSQL, MS-SQL, MySQL, Oracle, Informix, PostgreSQL, Sybase]
Hibernate: select author0_.AUTHOR_ID as AUTHOR1_, author0_.AUTHOR_SEX as AUTHOR2_1_, author0_.AUTHOR_MEMO as AUTHOR3_1_, author0_.AUTHOR_EMAIL as AUTHOR4_1_, author0_.AUTHOR_NAME as AUTHOR5_1_, author0_.AUTHOR_AGE as AUTHOR6_1_ from AUTHOR author0_
2005-08-11 12:30:08,736 [main] WARN org.hibernate.jdbc.AbstractBatcher - exception clearing maxRows/queryTimeout
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]optional function not implement
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLGetStmtOption(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcStatement.getStmtOption(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcStatement.getQueryTimeout(Unknown Source)
at org.apache.commons.dbcp.DelegatingStatement.getQueryTimeout(DelegatingStatement.java:243)
at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:205)
at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:143)
at org.hibernate.loader.Loader.doQuery(Loader.java:433)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.doList(Loader.java:1593)
at org.hibernate.loader.Loader.list(Loader.java:1577)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:844)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at org.springframework.orm.hibernate3.HibernateTemplate$29.doInHibernate(HibernateTemplate.java:748)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:310)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:739)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:731)
at lyo.hotmail.service.BaseDAOImpl.getAuthors(BaseDAOImpl.java:29)
at lyo.hotmail.dao.TestAuthorDAOImpl.testGetAuthors(TestAuthorDAOImpl.java:43)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
Get Author: [lyo.hotmail.domain.Author@19ec4ed]
Hibernate: select author0_.AUTHOR_ID as AUTHOR1_, author0_.AUTHOR_SEX as AUTHOR2_1_, author0_.AUTHOR_MEMO as AUTHOR3_1_, author0_.AUTHOR_EMAIL as AUTHOR4_1_, author0_.AUTHOR_NAME as AUTHOR5_1_, author0_.AUTHOR_AGE as AUTHOR6_1_ from AUTHOR author0_
2005-08-11 12:30:09,077 [main] WARN org.hibernate.jdbc.AbstractBatcher - exception clearing maxRows/queryTimeout
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]optional function not implement
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLGetStmtOption(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcStatement.getStmtOption(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcStatement.getQueryTimeout(Unknown Source)
at org.apache.commons.dbcp.DelegatingStatement.getQueryTimeout(DelegatingStatement.java:243)
at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:205)
at org.hibernate.jdbc.AbstractBatcher.closeQueryStatement(AbstractBatcher.java:143)
at org.hibernate.loader.Loader.doQuery(Loader.java:433)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
at org.hibernate.loader.Loader.doList(Loader.java:1593)
at org.hibernate.loader.Loader.list(Loader.java:1577)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:395)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:271)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:844)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at org.springframework.orm.hibernate3.HibernateTemplate$29.doInHibernate(HibernateTemplate.java:748)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:310)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:739)
at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:731)
at lyo.hotmail.service.BaseDAOImpl.getAuthors(BaseDAOImpl.java:29)
at lyo.hotmail.dao.TestAuthorDAOImpl.testGetAuthors(TestAuthorDAOImpl.java:44)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
Access 2002 (Office XP):
Hibernate: select author0_.AUTHOR_ID as AUTHOR1_, author0_.AUTHOR_SEX as AUTHOR2_1_, author0_.AUTHOR_MEMO as AUTHOR3_1_, author0_.AUTHOR_EMAIL as AUTHOR4_1_, author0_.AUTHOR_NAME as AUTHOR5_1_, author0_.AUTHOR_AGE as AUTHOR6_1_ from AUTHOR author0_
INFO:
Hi everyone:
I want to use MS Access with Hibernate3,but when I run a simple JUnit test,it throw exception:
Code:
java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]optional function not implement
.My config file is:
Code:
<beans>
<bean id="MyDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<!-- results in a setDriverClassName(String) call -->
<property name="driverClassName">
<value>sun.jdbc.odbc.JdbcOdbcDriver</value>
</property>
<property name="url">
<value>jdbc:odbc:Accessforum</value>
</property>
<property name="username">
<value>user</value>
</property>
<property name="password">
<value></value>
</property>
<property name="defaultAutoCommit">
<value>false</value>
</property>
</bean>
<!--
<bean id="MyJNDIDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>jdbc/mysql</value>
</property>
</bean>
-->
<bean id="MySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="mappingResources">
<list>
<value>lyo/hotmail/domain/Article.hbm.xml</value>
<value>lyo/hotmail/domain/Author.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
[color=red][b]<prop key="hibernate.dialect">org.hibernate.dialect.GenericDialect</prop>[/b][/color] <prop key="hibernate.query.substitutions">true=1 false=0</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.use_outer_join">false</prop>
</props>
</property>
<property name="dataSource"><ref bean="MyDataSource"/></property>
</bean>
<bean id="baseDao" class="lyo.hotmail.service.BaseDAOImpl">
<property name="sessionFactory">
<ref bean="MySessionFactory"/>
</property>
</bean>
</beans>
There is no access Dialect in hibernate implement,so I use
GenericDialect.
Couldn't I use Hibernate with MS Access? Could Hibernate could work with jdbc-odbc driver? Thks!