Tuesday, 29 April 2008

Using the ruby oracle_adapter on Windows XP

I have been having some problems getting my windows install of ruby to connect to oracle. It is so much easier on ubuntu. Looking at the blog of a friend Andrew Beacock other people have had the same problem, admittedly a while ago.

I tried the gem install command:
gem install activerecord-oracle-adapter
with no luck.

I tried
gem install activerecord-oracle-adapter --source http://gems.rubyforge.org
also with no luck.

Then I tried this. I am sure it is not the purist solution but it works !!!
Download the oracle_adapter.rb

Then copy this into the relevant directory under where you have ruby installed.
C:\ruby\lib\ruby\gems\1.8\gems\activerecord-2.0.2\lib\active_record\connection_adapters

And bobs your father's brother ...

My database.yml file looks like this:
development:
adapter: oracle
database: my_sid
username: my_user
password: my_password

Saturday, 5 April 2008

hibernate3 - hibernateQueryException - Class is not mapped

I have been having a problem for a while trying to get a basic hibernate3 and Spring 2.5 example working. Using old style hibernate CLASS_NAME.hbm.xml files worked fine. When I changed the context.xml file to try & use annotations instead I got the following error:

Exception in thread "main" org.springframework.orm.hibernate3.HibernateQueryException:
Test is not mapped [from Test t where t.name = ?];
nested exception is org.hibernate.hql.ast.QuerySyntaxException:
Test is not mapped [from Test t where t.name = ?] at
org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:640)


Check the imports of your '@Entity' annotations in your beans

If it is:
    org.hibernate.annotations.Entity;
Then change it to:
    import javax.persistence.Entity;
and life will be sweet.