-->
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.  [ 1 post ] 
Author Message
 Post subject: Using both HSQL and native SQL with the same mapping files
PostPosted: Fri Jan 26, 2007 7:43 am 
Beginner
Beginner

Joined: Mon Aug 02, 2004 7:28 am
Posts: 38
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.1

Mapping documents:
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="biz.c24.io.fix44.equitytrades" auto-import="false">
<class lazy="false" table="customer_data" name="biz.c24.io.fix44.equitytrades.Customer_data">
<id name="CustomerNumber" column="Customer Number">
<generator class="native"/>
</id>
<property column="Customer Acronym" type="java.lang.String"
length="12"
access="biz.c24.io.api.presentation.hibernate.PropertyAccessor"
not-null="false" name="CustomerAcronym"/>
<property column="Address Line 1" type="java.lang.String"
length="50"
access="biz.c24.io.api.presentation.hibernate.PropertyAccessor"
not-null="false" name="AddressLine1"/>
<property column="Address Line 2" type="java.lang.String"
length="50"
access="biz.c24.io.api.presentation.hibernate.PropertyAccessor"
not-null="false" name="AddressLine2"/>
<property column="Address Line 3" type="java.lang.String"
length="50"
access="biz.c24.io.api.presentation.hibernate.PropertyAccessor"
not-null="false" name="AddressLine3"/>
<property column="Address Line 4" type="java.lang.String"
length="50"
access="biz.c24.io.api.presentation.hibernate.PropertyAccessor"
not-null="false" name="AddressLine4"/>
<property column="Address Line 5" type="java.lang.String"
length="50"
access="biz.c24.io.api.presentation.hibernate.PropertyAccessor"
not-null="false" name="AddressLine5"/>
<property column="PostZip Code" type="java.lang.String"
length="8"
access="biz.c24.io.api.presentation.hibernate.PropertyAccessor"
not-null="false" name="PostZipCode"/>
<property column="Tel Number" type="java.lang.String"
length="20"
access="biz.c24.io.api.presentation.hibernate.PropertyAccessor"
not-null="false" name="TelNumber"/>
<property column="Email Address" type="java.lang.String"
length="50"
access="biz.c24.io.api.presentation.hibernate.PropertyAccessor"
not-null="false" name="EmailAddress"/>
<property column="BIC" type="java.lang.String" length="11"
access="biz.c24.io.api.presentation.hibernate.PropertyAccessor"
not-null="false" name="BIC"/>
<property column="Fax Number" type="java.lang.String"
length="20"
access="biz.c24.io.api.presentation.hibernate.PropertyAccessor"
not-null="false" name="FaxNumber"/>
<property column="Telex Number" type="java.lang.String"
length="20"
access="biz.c24.io.api.presentation.hibernate.PropertyAccessor"
not-null="false" name="TelexNumber"/>
<property column="Country Of Residence" type="java.lang.String"
length="2"
access="biz.c24.io.api.presentation.hibernate.PropertyAccessor"
not-null="false" name="CountryOfResidence"/>
<property column="Fedwire Code" type="java.lang.String"
length="9"
access="biz.c24.io.api.presentation.hibernate.PropertyAccessor"
not-null="false" name="FedwireCode"/>
<property column="Chips Participant Code"
type="java.lang.String" length="4"
access="biz.c24.io.api.presentation.hibernate.PropertyAccessor"
not-null="false" name="ChipsParticipantCode"/>
<property column="Chips UID" type="java.lang.String" length="6"
access="biz.c24.io.api.presentation.hibernate.PropertyAccessor"
not-null="false" name="ChipsUID"/>
<property column="Sort Code" type="java.lang.String" length="6"
access="biz.c24.io.api.presentation.hibernate.PropertyAccessor"
not-null="false" name="SortCode"/>
<property column="Bankleitzhal Code" type="java.lang.String"
length="8"
access="biz.c24.io.api.presentation.hibernate.PropertyAccessor"
not-null="false" name="BankleitzhalCode"/>
</class>
</hibernate-mapping>



Code between sessionFactory.openSession() and session.close():
FOR SQL:
Code:
SQLQuery query = session.createSQLQuery(sqlQuery);
                        if (object != null && !object.getType().isExcludeFromDatabase())
                            query.addEntity(object.getType().getValidObjectClass());
                        else if (object != null && object.getType().isExcludeFromDatabase())
                        {
                            for (int i = 0; i < object.getType().getElementDeclCount(); i++)
                                query.addEntity(object.getType().getElementDecl(i).getType().getValidObjectClass());
                        }

                        List objects = query.list();

FOR HSQL:

Code:
Query query = session.createQuery(hqlQuery);
                        List objects = query.list();


Full stack trace of any exception that occurs:

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

The generated SQL (show_sql=true):
select customer_d0_.Customer Number as Customer1_12_, customer_d0_.Customer Acronym as Customer2_12_, customer_d0_.Address Line 1 as Address3_12_, customer_d0_.Address Line 2 as Address4_12_, customer_d0_.Address Line 3 as Address5_12_, customer_d0_.Address Line 4 as Address6_12_, customer_d0_.Address Line 5 as Address7_12_, customer_d0_.PostZip Code as PostZip8_12_, customer_d0_.Tel Number as Tel9_12_, customer_d0_.Email Address as Email10_12_, customer_d0_.BIC as BIC12_, customer_d0_.Fax Number as Fax12_12_, customer_d0_.Telex Number as Telex13_12_, customer_d0_.Country Of Residence as Country14_12_, customer_d0_.Fedwire Code as Fedwire15_12_, customer_d0_.Chips Participant Code as Chips16_12_, customer_d0_.Chips UID as Chips17_12_, customer_d0_.Sort Code as Sort18_12_, customer_d0_.Bankleitzhal Code as Banklei19_12_ from customer_data customer_d0_



The mapping above works with native SQL(Select * from customer_data). But when I try to run the HSQL against the same mappings, the above SQL fails due to spaces in the column names.

However, when I add the `` to column names with spaces in, then the HSQL works, but the native SQL fails, because the column name it tries to set contains the `` and the original one doesn't.

I tried the NamingStrategy Class, but it didn't solve my problem.

Any help would be greatly appreciated.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.