-->
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: missing quotes in generated SQL around string literal, help!
PostPosted: Sat May 21, 2005 3:02 am 
Newbie

Joined: Sat May 21, 2005 2:54 am
Posts: 2
Hibernate version: 3.0

Mapping documents:

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

Full stack trace of any exception that occurs:

Name and version of the database you are using: postgreSQL 8.0.3

The generated SQL (show_sql=true):
insert into groups (name,description,id) values (fooname, bar,1)

Debug level Hibernate log excerpt:

Hi,
I am a beginner and please help. Basically I have a very table "groups", which has 3 columns: id: au auto-generated sequence; name: char; description: char.

and when I try to insert a row with name's value "fooname", description's value "bar", I see from the log that hibernate generates the above sql without quotes around the string literals for the columns name and description. As a result I got GrammarException.

When I take that sql to postgres and manually run it, it fails also.
I added quotes around fooname and bar, then it succeeds - that is the correct sql syntax.

Why does the hibernate not surround string literals with quotes? is there a setting something I can configure?

Thanks for help!
lwen


Top
 Profile  
 
 Post subject: Re: missing quotes in generated SQL around string literal, h
PostPosted: Sat May 21, 2005 3:08 am 
Newbie

Joined: Sat May 21, 2005 2:04 am
Posts: 2
Did you set hibernate.dialect value in hibernate.properties correctly?


Top
 Profile  
 
 Post subject: I think so, but here are my configurations
PostPosted: Sat May 21, 2005 3:14 am 
Newbie

Joined: Sat May 21, 2005 2:54 am
Posts: 2
hibernate.cfg.xml:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.datasource">java:/comp/env/jdbc/gc</property>
<property name="hibernate.connection.driver_class">
org.postgresql.Driver
</property>
<property name="hibernate.connection.url">
jdbc:postgresql://localhost:5432/pg
</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<!-- Mapping files -->
<mapping resource="gc.hbm.xml"/>
</session-factory>
</hibernate-configuration>

And btw I am using spring (but this probably is not related), and here is my spring context configuration file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>
<!-- ========================= Start of PERSISTENCE DEFINITIONS ========================= -->

<!-- Choose the dialect that matches your "dataSource" definition -->
<bean id="mySessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="mappingResources">
<list>
<value>com/good/gc/group/bean/Group.hbm.xml</value>
</list>
</property>

<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
<prop key="hibernate.proxool.xml">proxool.xml</prop>
<prop key="hibernate.proxool.pool_alias">spring</prop>
</props>
</property>
</bean>

<!-- Transaction manager for a single Hibernate SessionFactory (alternative to JTA) -->
<bean id="myTransactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory"><ref local="mySessionFactory"/></property>
</bean>


<!-- ***** Group Business Logic*****-->
<bean id="groupBL" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager"><ref local="myTransactionManager"/></property>
<property name="target"><ref local="groupTarget"/></property>
<property name="transactionAttributes">
<props>
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="save*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>

<!-- GroupTarget primary business object implementation -->
<bean id="groupTarget" class="com.good.gc.group.bl.GroupBLImpl">
<property name="groupDAO"><ref local="groupDAO"/></property>
</bean>

<!-- DAO object: Hibernate implementation -->
<bean id="groupDAO" class="com.good.gc.group.da.GroupDAOImpl">
<property name="sessionFactory"><ref local="mySessionFactory"/></property>
</bean>


<!-- Add more services here -->

</beans>

Thanks so much for helping me!


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.