Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
madeinoz
Post subject: [Closed] Generating many-one HSQLDB not happening  PostPosted: Mar 15, 2006 - 03:02 PM
Veteran Member
Veteran Member


Joined: Jan 17, 2004
Posts: 45

G'day Guys,

Having a problem generating a simple many-one relationships from the 'create hibernate mapping wizard' in the DB Explorer. Using HSQLDB version 1.8.0.2 as a standalone database in this project.

I've come across previous posts regarding similar problems and have tried the select all tables and generate, but still fails to create the relationship mappings within the mapping files.

pojos are all created and mapping files are created...just no many-one mappings in the relevant mapping files.

ER mapper shows correct relationships.

Code:

drop table SENSOR_DATA if exists;
drop table SENSORS if exists;

create table "SENSORS"(
"SID" INTEGER(0) not null,
"NAME" VARCHAR(16) not null,
"DESCRIPTION" VARCHAR(0),
"TYPE" VARCHAR(0) not null,
"UNIT" VARCHAR(4)not null,
"PORT" VARCHAR(5) not null,

primary key (sid)

)

create table "SENSOR_DATA"(
"ID" INTEGER(0) not null,
"SID" INTEGER(0) not null,
"TIME" TIMESTAMP default 'now',
"VALUE" DOUBLE not null,

primary key(id),
foreign key(sid) references SENSORS(sid)

)


insert into SENSORS(sid,name,description,type,unit,port) values (1,'Temp1','Server room temperature','TEMP','DEGC','COM6');



Quote:

*** Date: Wed Mar 15 22:15:19 WST 2006

*** System properties:
OS=WindowsXP
OS version=5.1
Java version=1.5.0_04

*** MyEclipse details:
MyEclipse Enterprise Workbench

Version: 4.1.1 GA
Build id: 20060228-4.1.1-GA

*** Eclipse details:
Eclipse SDK

Version: 3.1.0
Build id: I20050627-1435

Eclipse Platform

Version: 3.1.0
Build id: I20050627-1435

Eclipse RCP

Version: 3.1.0
Build id: I20050627-1435

Eclipse Java Development Tools

Version: 3.1.0
Build id: I20050627-1435

Eclipse Plug-in Development Environment

Version: 3.1.0
Build id: I20050627-1435

Eclipse Project SDK

Version: 3.1.0
Build id: I20050627-1435

Eclipse startup command=-os
win32
-ws
win32
-arch
x86
-launcher
C:\java\eclipse_3_1\eclipse.exe
-name
Eclipse
-showsplash
600
-exitdata
1398_44
-vm
C:\WINDOWS\SYSTEM32\javaw.exe

Code:
Code:
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
support-snpe
Post subject:   PostPosted: Mar 15, 2006 - 04:01 PM
Moderator
Moderator


Joined: Feb 03, 2006
Posts: 1117

madeinoz,

I have tried reproduce your case.I have to change your schema, because constructions INTEGER(0) or VARCHAR(0) are invalid
This is schema script (i run it from myeclipse sql editor on hsqldb 1.8.0)
Code:

drop table SENSOR_DATA if exists;
drop table SENSORS if exists;

create table "SENSORS"(
"SID" INTEGER not null,
"NAME" VARCHAR(16) not null,
"DESCRIPTION" VARCHAR(20),
"TYPE" VARCHAR(20) not null,
"UNIT" VARCHAR(4)not null,
"PORT" VARCHAR(5) not null,
primary key (sid)
)

create table "SENSOR_DATA"(
"ID" INTEGER not null,
"SID" INTEGER not null,
"TIME" TIMESTAMP default 'now',
"VALUE" DOUBLE not null,
primary key(id),
foreign key(sid) references SENSORS(sid)
)

insert into SENSORS(sid,name,description,type,unit,port) values (1,'Temp1','Server room temperature','TEMP','DEGC','COM6');


When i call hibernate mapping for this tables, I get next (many-to-one and one-to-many have created)

Code:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
    Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping>
    <class name="test.Sensors" table="SENSORS" schema="PUBLIC">
        <id name="sid" type="integer">
            <column name="SID" />
            <generator class="assigned" />
        </id>
        <property name="name" type="string">
            <column name="NAME" length="16" not-null="true" />
        </property>
        <property name="description" type="string">
            <column name="DESCRIPTION" length="20" />
        </property>
        <property name="type" type="string">
            <column name="TYPE" length="20" not-null="true" />
        </property>
        <property name="unit" type="string">
            <column name="UNIT" length="4" not-null="true" />
        </property>
        <property name="port" type="string">
            <column name="PORT" length="5" not-null="true" />
        </property>
        <set name="sensorDatas" inverse="true">
            <key>
                <column name="SID" not-null="true" />
            </key>
            <one-to-many class="test.SensorData" />
        </set>
    </class>
</hibernate-mapping>


<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!--
    Mapping file autogenerated by MyEclipse - Hibernate Tools
-->
<hibernate-mapping>
    <class name="test.SensorData" table="SENSOR_DATA" schema="PUBLIC">
        <id name="id" type="integer">
            <column name="ID" />
            <generator class="assigned" />
        </id>
        <many-to-one name="sensors" class="test.Sensors" fetch="select">
            <column name="SID" not-null="true" />
        </many-to-one>
        <property name="time" type="timestamp">
            <column name="TIME" length="6" />
        </property>
        <property name="value" type="double">
            <column name="VALUE" precision="0" scale="0" not-null="true" />
        </property>
    </class>
</hibernate-mapping>


I make test for simple query (loading classes) and it work fine.
If you have mapping and POJO then you probably haven't PK or FK
Check this in DB Explorer (click on table and see Table Info view)

Best
 
 View user's profile Send private message  
Reply with quote Back to top
madeinoz
Post subject:   PostPosted: Mar 15, 2006 - 11:23 PM
Veteran Member
Veteran Member


Joined: Jan 17, 2004
Posts: 45

Thanks for the quick response...I'll follow up on those and get back to you.
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
madeinoz
Post subject:   PostPosted: Mar 16, 2006 - 04:40 AM
Veteran Member
Veteran Member


Joined: Jan 17, 2004
Posts: 45

Hmm...Tried and still failing....the VARCHAR(0) anf INTEGER(0) were as generated from the DB browser. Even if I copy and paste your script it still returns INTEGER(0) on the generated table script.

I must be missing something in the steps. When I generate the mappings I select the tables from DB Browser, click on generate Hibernate Mapping, then with the wizard I just hit next, next, next then Finish.

To rule out my installation I have re-installed from afresh, both Eclipse and Myeclipse. Config below. I noticed from my config that it's using Java version=1.5.0_04. what Jversion should I be using for myeclipse? 1.4? Where do I set this for myeclipse? or is it getting it from the system environment?

Quote:

*** Date: Thu Mar 16 12:29:01 WST 2006

*** System properties:
OS=WindowsXP
OS version=5.1
Java version=1.5.0_04

*** MyEclipse details:
MyEclipse Enterprise Workbench

Version: 4.1.1 GA
Build id: 20060309-4.1.1-GA

*** Eclipse details:
Eclipse SDK

Version: 3.1.2
Build id: M20060118-1600

Eclipse Platform

Version: 3.1.2
Build id: M20060118-1600

Eclipse RCP

Version: 3.1.2
Build id: M20060118-1600

Eclipse Java Development Tools

Version: 3.1.2
Build id: M20060118-1600

Eclipse Plug-in Development Environment

Version: 3.1.2
Build id: M20060118-1600

Eclipse Project SDK

Version: 3.1.2
Build id: M20060118-1600

Eclipse startup command=-os
win32
-ws
win32
-arch
x86
-launcher
C:\java\eclipse\eclipse.exe
-name
Eclipse
-showsplash
600
-exitdata
11f0_3c
-vm
C:\WINDOWS\SYSTEM32\javaw.exe
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
madeinoz
Post subject:   PostPosted: Mar 16, 2006 - 07:16 AM
Veteran Member
Veteran Member


Joined: Jan 17, 2004
Posts: 45

Ok All fixed.....Found the problem was the actual HSQLDB Jar File I was using was infact 1.7.0.x not 1.8.0.x I had picked up the wrong one when I configured my driver. This also seems to have fixed the INTEGER(0) issue on the generated script.

Thanks again for you help :)
 
 View user's profile Send private message Visit poster's website  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT - 6 Hours
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits