-->
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.  [ 3 posts ] 
Author Message
 Post subject: How to change db from oracle to mysql with change the code?
PostPosted: Mon Jun 19, 2006 7:14 am 
Newbie

Joined: Mon Jun 19, 2006 6:49 am
Posts: 2
Hibernate version:hibernate-2.1


Code between sessionFactory.openSession() and session.close():

Session session = HibernateUtil.currentSession();
Criteria criteria = session.createCriteria(VTemplate.class)
.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY)
.add(Example.create(info).enableLike(MatchMode.ANYWHERE));

criteria.setFirstResult(firstResult);
criteria.setMaxResults(maxResult);
list = criteria.list();


Full stack trace of any exception that occurs:
18:46:46,187 WARN [JDBCExceptionReporter] SQL Error: 1248, SQLState: 42000
18:46:46,187 ERROR [JDBCExceptionReporter] Every derived table must have its own
alias
18:46:46,187 WARN [JDBCExceptionReporter] SQL Error: 1248, SQLState: 42000
18:46:46,187 ERROR [JDBCExceptionReporter] Every derived table must have its own
alias
18:46:46,203 ERROR [MyEjbWrapper] MyEjb.exception.DaoEx
ception: Unable to perform find


Name and version of the database you are using:MySQL 5.0/Oracle9:

I want to change the database form oracle to the open source database mysql. I suppose that it could without change the code(like that posted). I modified the jdbc, but an exception breaks out.
I don't know how to do?Please help~


btw, the following code is ok, but the posted one isn't.:

Session session = HibernateUtil.currentSession();
Criteria criteria = session.createCriteria(MyObj.class)
.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY)
.add(Example.create(info).enableLike(MatchMode.ANYWHERE));

_________________
make it fun~


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 19, 2006 8:51 am 
Beginner
Beginner

Joined: Tue Jun 28, 2005 4:33 pm
Posts: 21
change the dialect class (hibernate.dialect) from oracle to mysql in your sessionfactory configuration.

Here's the reference link... http://www.hibernate.org/hib_docs/v3/re ... l-dialects


Top
 Profile  
 
 Post subject: Thank you~
PostPosted: Mon Jun 19, 2006 11:17 am 
Newbie

Joined: Mon Jun 19, 2006 6:49 am
Posts: 2
Thank you, that is what i want~!

_________________
make it fun~


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.