-->
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.  [ 7 posts ] 
Author Message
 Post subject: how to genrate mapping wihout other class for PK?
PostPosted: Wed Jan 19, 2005 1:31 am 
Regular
Regular

Joined: Sat Apr 10, 2004 8:39 pm
Posts: 84
middlegen r5:

i like tables being mappinged as


<hibernate-mapping>
<class
name="com.fjky.fzgs.hibernate.WsDjxx"
table="WS_DJXX"
>

<composite-id>
<key-property
name="nsrsbh"
column="NSRSBH"
type="java.lang.String"
length="20"
/>
<key-property
name="wspzxh"
column="WSPZXH"
type="java.lang.String"
length="15"
/>
</composite-id>

<property
name="wsdlDm"
type="java.lang.String"
column="WSDL_DM"
not-null="true"
length="2"
/>
<property
name="wszlDm"
type="java.lang.String"
column="WSZL_DM"
not-null="true"
length="5"
/>
<!-- associations -->
</class>
</hibernate-mapping>


it mappings like
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >

<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.1

http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->

<class
name="com.fjky.hibernate.SbSbxx"
table="SB_SBXX"
>

<composite-id name="comp_id" class="com.fjky.hibernate.SbSbxxPK"> ------------------------------here I don't like other class for PK --------------- how to generate as obove? thanks

<key-property
name="pzxh"
column="PZXH"
type="java.lang.String"
length="16"
/>
<key-property
name="zsxmDm"
column="ZSXM_DM"
type="java.lang.String"
length="2"
/>
</composite-id>

<property
name="nsrsbh"
type="java.lang.String"
column="NSRSBH"
not-null="true"
length="20"
/>

</class>
</hibernate-mapping>

_________________
I am the creatxr of world.


Top
 Profile  
 
 Post subject: but if
PostPosted: Wed Jan 19, 2005 1:47 am 
Regular
Regular

Joined: Sat Apr 10, 2004 8:39 pm
Posts: 84
but when I use genIntergratedCompositeKeys="true"

hbm2ddl can't work.

is there any way ?

_________________
I am the creatxr of world.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 19, 2005 5:51 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
You found the option - great.

You did not provide anywhere near enough information to answer your other question. In anycase, the DDL generated will be the same from either mapping.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 22, 2005 11:29 am 
Regular
Regular

Joined: Sat Apr 10, 2004 8:39 pm
Posts: 84
for example:

create table xresource_relation (
id integer not null,
friend_id integer not null,
title varchar(30) default 'no title' not null,
note varchar(512),
primary key(id,friend_id),
foreign key(id) references xresource(id),
foreign key(friend_id) references xresource(id)
);

======================================
I set
genIntergratedCompositeKeys="true"
for generate hbm.

=============================================
<target name="hbm2ddl" description="Generate .sql from .hbm files">
<taskdef
name="schemaexport"
classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask"
classpathref="lib.hbm2ddl.path"
/>

<schemaexport
properties="${build.classes.dir}/hibernate.properties"
quiet="no"
text="yes"
drop="no"
delimiter=";"
output="${build.dir}/schema-export.sql"
>
<fileset dir="${build.gen-src.dir}/com/fjky/orm">
<include name="**/*.hbm.xml"/>
</fileset>
</schemaexport>
</target>
=====================================

[schemaexport] net.sf.hibernate.MappingException: composite-id class must overri
de equals(): com.fjky.orm.hibernate.XresourceRelation
[schemaexport] at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:306)
[schemaexport] at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1257)
[schemaexport] at net.sf.hibernate.cfg.Configuration.add(Configuration.java:252
)
[schemaexport] at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java
:174)
[schemaexport] at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.getConfigurati
on(SchemaExportTask.java:195)
[schemaexport] at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.execute(Schema
ExportTask.java:135)
[schemaexport] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.ja
va:275)
[schemaexport] at org.apache.tools.ant.Task.perform(Task.java:364)
[schemaexport] at org.apache.tools.ant.Target.execute(Target.java:341)
[schemaexport] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[schemaexport] at org.apache.tools.ant.Project.executeTarget(Project.java:1214)

[schemaexport] at org.apache.tools.ant.Project.executeTargets(Project.java:1062
)
[schemaexport] at org.apache.tools.ant.Main.runBuild(Main.java:673)
[schemaexport] at org.apache.tools.ant.Main.startAnt(Main.java:188)
[schemaexport] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
[schemaexport] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)
[schemaexport] (cfg.Configuration 178 ) Could not configure da
tastore from file: D:\Program Files\Middlegen-Hibernate-r5\build\gen-src\com\fjk
y\orm\hibernate\XresourceRelation.hbm.xml
[schemaexport] net.sf.hibernate.MappingException: composite-id class must overri
de equals(): com.fjky.orm.hibernate.XresourceRelation
[schemaexport] at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:306)
[schemaexport] at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1257)
[schemaexport] at net.sf.hibernate.cfg.Configuration.add(Configuration.java:252
)
[schemaexport] at net.sf.hibernate.cfg.Configuration.addFile(Configuration.java
:174)
[schemaexport] at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.getConfigurati
on(SchemaExportTask.java:195)
[schemaexport] at net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.execute(Schema
ExportTask.java:135)
[schemaexport] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.ja
va:275)
[schemaexport] at org.apache.tools.ant.Task.perform(Task.java:364)
[schemaexport] at org.apache.tools.ant.Target.execute(Target.java:341)
[schemaexport] at org.apache.tools.ant.Target.performTasks(Target.java:369)
[schemaexport] at org.apache.tools.ant.Project.executeTarget(Project.java:1214)

[schemaexport] at org.apache.tools.ant.Project.executeTargets(Project.java:1062
)
[schemaexport] at org.apache.tools.ant.Main.runBuild(Main.java:673)
[schemaexport] at org.apache.tools.ant.Main.startAnt(Main.java:188)
[schemaexport] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:196)
[schemaexport] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:55)

BUILD FAILED
D:\Program Files\Middlegen-Hibernate-r5\custom.build.xml:277: Schema text failed
: net.sf.hibernate.MappingException: composite-id class must override equals():
com.fjky.orm.hibernate.XresourceRelation

Total time: 5 seconds
===============================================

if I want to do hbm2ddl , must I use composite-id class not Intergrated Composite Keys ???????????

_________________
I am the creatxr of world.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 22, 2005 11:51 am 
Regular
Regular

Joined: Sat Apr 10, 2004 8:39 pm
Posts: 84
I found the reasons.
I've to override the methods equals and hashCode for composite-id.

but, middlegen r5 why not do it for us?

is there any options in the build.xml ??????????

_________________
I am the creatxr of world.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 22, 2005 6:01 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
I suppose your correct - middlegen could do that automatically for you in that mode now that hbm2java has that option. You could create a SF Bug track entry to remind me of this suggestion.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 22, 2005 6:03 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
BTW: See the Middlegen web site for all (bulk) of the Ant options.


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