-->
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.  [ 4 posts ] 
Author Message
 Post subject: ERROR: column notation applied to type name
PostPosted: Tue Apr 19, 2005 11:01 am 
Newbie

Joined: Tue Mar 15, 2005 6:07 am
Posts: 9
Location: Kiev, Ukraine
Hi friends,


I'm starting with Hibernate - please help me to find out what is wrong. I'm using PostgreSQL and I got this exception
Code:
Hibernate: select userentity0_.USER_ID as USER_ID, userentity0_.FIRST_NAME as FIRST_NAME, userentity0_.LAST_NAME as LAST_NAME from USER userentity0_
19/4/2005 17:42:18 net.sf.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 0, SQLState: 42809
19/4/2005 17:42:18 net.sf.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: ERROR: column notation .user_id applied to type name, which is not a composite type
19/4/2005 17:42:18 net.sf.hibernate.util.JDBCExceptionReporter logExceptions
WARNING: SQL Error: 0, SQLState: 42809
19/4/2005 17:42:18 net.sf.hibernate.util.JDBCExceptionReporter logExceptions
SEVERE: ERROR: column notation .user_id applied to type name, which is not a composite type
19/4/2005 17:42:18 net.sf.hibernate.JDBCException <init>
SEVERE: Could not execute query
java.sql.SQLException: ERROR: column notation .user_id applied to type name, which is not a composite type
   at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1471)
   at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1256)
   at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:175)
   at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:388)
   at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:329)
   at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:239)
   at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:92)
   at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:87)
...

My hibernate.cfg.xml
Code:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
   <session-factory>
      <property name="show_sql">true</property>
      <property name="connection.datasource">
         java:/comp/env/jdbc/webnames
      </property>
      <property name="dialect">
         net.sf.hibernate.dialect.PostgreSQLDialect
      </property>
      <mapping
         resource="org/dotuseful/web/webnames/pd/UserEntity.hbm.xml" />
   </session-factory>
</hibernate-configuration>

My UserEntity.hbm.xml
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
   <class name="org.dotuseful.web.webnames.pd.UserEntity"
      table="USER">
      <id name="id" type="string">
         <column name="USER_ID" sql-type="char(32)" />
         <generator class="uuid.hex" />
      </id>
      <property name="firstName" column="FIRST_NAME" type="string" />
      <property name="lastName" column="LAST_NAME" type="string" />
   </class>
</hibernate-mapping>

My USER table
Code:
CREATE TABLE "USER"
(
  "ID" varchar(32),
  "FIRST_NAME" varchar,
  "LAST_NAME" varchar
)
WITHOUT OIDS;

Thanks for help!

_________________
Denis Krukovsky
http://dotuseful.sourceforge.net/


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 19, 2005 11:13 am 
Newbie

Joined: Tue Mar 15, 2005 6:07 am
Posts: 9
Location: Kiev, Ukraine
SHOULD READ
My USER table
Code:
CREATE TABLE "USER"
(
  "USER_ID" varchar(32),
  "FIRST_NAME" varchar,
  "LAST_NAME" varchar
)
WITHOUT OIDS;

_________________
Denis Krukovsky
http://dotuseful.sourceforge.net/


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 20, 2005 4:16 am 
Newbie

Joined: Tue Mar 15, 2005 6:07 am
Posts: 9
Location: Kiev, Ukraine
Friends,

I was pretty surprised with a level of support I got on this forum before. It was fast and constructive. Please help me with making Hibernate working with PostgreSQL. I'm sure we have a lot of people who are using Hibernate with it. I'm using PostgreSQL 8.0.2 for Windows.

Thank you in advance.

_________________
Denis Krukovsky
http://dotuseful.sourceforge.net/


Top
 Profile  
 
 Post subject: Re: ERROR: column notation applied to type name
PostPosted: Tue Aug 03, 2010 5:14 am 
Newbie

Joined: Tue Aug 03, 2010 5:04 am
Posts: 2
This post is pretty old but I am posting the solution just for fullness.

The problem is that you name your table with reserved name "user" in postgres. Hibernate will generate query that will not succeed:
Code:
select
    user0_.id as id0_,
    user0_.first_name as first2_0_,
    user0_.last_name as last3_0_,
from
    user user0_

This user in the from clause messes the things.

The work around is to specify your schema. Can be done in two ways (The solution is for post JPA 1 implementation)

1. By specifying the schema in the table in the @Table annotation. In case of schema public, will look like this.

Code:
@Entity
@Table(schema=”public”, name = “user”)

2. By specifying the schema in the schema in the persistence.xml

Code:
<property name="hibernate.default_schema" value="public"/>


This will crate a query that works:
Code:
select
    user0_.id as id0_,
    user0_.first_name as first2_0_,
    user0_.last_name as last3_0_,
from
    public.user user0_


Note that public.user in the FROM clause. This will work.

Hope that this one will help.


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