-->
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.  [ 2 posts ] 
Author Message
 Post subject: strange postgres queries cause improper qualified name error
PostPosted: Thu Apr 05, 2007 11:26 pm 
Newbie

Joined: Thu Apr 05, 2007 11:11 pm
Posts: 4
Hello All,

I'm pretty much a newbie to J2EE, hibernate, and spring. I mapped out one simple pojo object and am attempting to retrieve a pre-populated version of the object from my Postgres database. The odd thing is that this was working before I started to work with the hibernatetemplate.save(), but something I've done has screwed everything up.

The query I'm seeing is really odd and basically breaks down to

Select [.. stuff ..] from org.hibernate.dialect.PostgreSQLDialect.BUDGET_USER [ .. where blah blah]

The exception I get is this:

WARNING: SQL Error: 0, SQLState: 42601
Apr 5, 2007 10:01:34 PM org.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: ERROR: improper qualified name (too many dotted names): org.hibernate.dialect.postgresqldialect.budget_user

The basic use case for the system as far as hibernate is concerned is thus:

a) get admin User from database for login auth
b) add another User to database.

When i started working on part (b) there I got an error about batch updates. I googled and searched around on that problem and found that I should wrap everything within transactions for the hibernatetemplate.save() call, so as you can see below I put some stuff in my spring config to get the transaction proxy up and working. The exception shown above from part (a) first appeared after I tried to put the transactin proxy stuff in.. so I commented out and reversed my transaction proxy additions and I'm still seeing that same error above.

Has anyone run across that sort of weird table name construction in sql queries before? My table is called "budget_user", obviously, but I dont understand why the org.hibernate namespace is being prepended to it in that query.


Hibernate version: 3

Mapping documents:

I do all of the hibernate configuration in spring.

spring file:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/b ... ns-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/a ... op-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/t ... tx-2.0.xsd">

<!-- services -->

<bean id="UserManager" class="DOM.Manager.UserManager">
<property name="userSession" ref="UserSession" />
<property name="exceptionManager" ref="MessageManager"/>
<property name="userDAO" ref="UserDAO" />
</bean>

<bean id="TransactionManager" class="DOM.Manager.TransactionManager">
<property name="userSession" ref="UserSession" />
<property name="exceptionManager" ref="MessageManager"/>
</bean>

<bean id="AccountManager" class="DOM.Manager.AccountManager">
<property name="userSession" ref="UserSession" />
<property name="exceptionManager" ref="MessageManager"/>
</bean>

<bean id="MessageManager" class="CalmSoftTags.MessageManager">
<property name="userSession" ref="UserSession" />
</bean>

<!-- session thread local beans -->

<bean id="UserSession" class="Context.UserSession" scope="session"><aop:scoped-proxy/></bean>

<!-- dao stuff -->
<bean id="UserDAO" class="DAO.UserDAOImpl">
<property name="sessionFactory" ref="mySessionFactory"/>
</bean>

<!-- transaction proxies -->

<!--
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory"><ref bean="mySessionFactory"/></property>
</bean>

<bean id="UserDAO" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager"><ref bean="transactionManager"/></property>
<property name="target"><ref bean="UserDAOTarget"/></property>
<property name="transactionAttributes">
<props>
<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
-->
<!-- hibernate crap -->

<!-- //todo: figure out what data source class to use here.. -->
<bean id="myDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="org.postgresql.Driver"/>
<property name="url" value="jdbc:postgresql://192.168.1.10:5432/budget"/>
<property name="username" value="devtest"/>
<property name="password" value="devtest"/>
</bean>

<bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="myDataSource"/>
<property name="mappingResources">
<list>
<value>mappings/User.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<value>
hibernate.default_schema=org.hibernate.dialect.PostgreSQLDialect
hibernate.show_sql=true
</value>
</property>
</bean>

</beans>

User.hbm.xml
<?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>
<class name="DOM.User" table="BUDGET_USER">
<id name="id" type="long" column="S_USER_ID">
<generator class="increment"/>
</id>

<version name="lastUpdated" type="timestamp" column="LAST_UPDATED_TS" />

<property name="deleted" type="boolean" column="DELETED_IND"/>
<property name="name" type="string" column="NAME"/>
<property name="email" type="string" column="EMAIL"/>
<property name="password" type="string" column="PASSWORD"/>
<property name="lastLogin" type="timestamp" column="LAST_LOGIN_TS"/>
<property name="loginCount" type="long" column="LOGIN_CNT"/>
<property name="admin" type="boolean" column="ADMIN_IND"/>
</class>
</hibernate-mapping>

Name and version of the database you are using:

Postgres 8.2 (latest stable version, just installed yesterday).

The generated SQL (show_sql=true):

select user0_.S_USER_ID as S1_0_, user0_.LAST_UPDATED_TS as LAST2_0_, user0_.DELETED_IND as DELETED3_0_, user0_.NAME as NAME0_, user0_.EMAIL as EMAIL0_, user0_.PASSWORD as PASSWORD0_, user0_.LAST_LOGIN_TS as LAST7_0_, user0_.LOGIN_CNT as LOGIN8_0_, user0_.ADMIN_IND as ADMIN9_0_ from org.hibernate.dialect.PostgreSQLDialect.BUDGET_USER user0_ where user0_.NAME=? or user0_.EMAIL=?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 06, 2007 5:50 pm 
Newbie

Joined: Thu Apr 05, 2007 11:11 pm
Posts: 4
Just an update on the fix to the issue. I failed to recognize that I had called one of my domain services classes "TransactionManager". It turns out the boiler-plate spring transaction configuration also named the DB transaction manager "TransactionManager". So my problem was probably that there were two classes called "TransactionManager" and who knows what kind of funky behaviour went on if spring was pushing my domain class instance in where the spring transaction manager should have been.


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