-->
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.  [ 2 posts ] 
Author Message
 Post subject: <one-to-many> without primary key and from several col
PostPosted: Mon Mar 06, 2006 3:08 pm 
Newbie

Joined: Mon Mar 06, 2006 9:41 am
Posts: 3
I am working with web-based online exam application and now I have little problem with hibernate mappings.

Hibernate version: 3.0.5

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

I have table called section that holds following kind of information:
Code:
SEid  integer PK
SEtyid char(1)
SEdate timestamp
SEtxt text
SEweight integer
SEguide1 text
SEguide2 text
SElang char(1)

Important fields in this problem are:
SETYid The type of the section (A,B,C,D or E)
SEguide1 Help text to be shown in user interface
SEguide2 Another help text
SElang language code

At the moment there are 16 different tests in the system so there are also 16 sections with type A, 16 with type B and so on. Because help texts in sections with certain type are quite similar, I have made table called parameter that holds default help texts to sections.
Code:
PAname varchar(10) PK
PAlang char(1) PK
PAsetyid char(1) PK
PAtxt text

The idea is that if SEguide1 and/or SEguide2 is null then application will show defalut text from parameter table. Connection between tables is SElang=PAlang and PAsetyid=SEtyid

Mapping documents:
Parameter.hbm.xml
Code:
<class name="Parameter" lazy="false" table="parameter" discriminator-value="foo.bar.Parameter" optimistic-lock="none">
    <composite-id name="id" class="foo.bar.Parameter$Id" unsaved-value="undefined">
      <key-property name="palang" type="character">
        <column name="PAlang" not-null="true" index="PRIMARY" length="1"/>
      </key-property>
      <key-property name="paname" type="string">
        <column name="PAname" not-null="true" index="PRIMARY" length="10"/>
      </key-property>
      <key-property name="pasetyid" type="character">
        <column name="PAsetyid" not-null="true" index="PRIMARY" length="1"/>
      </key-property>
    </composite-id>
    <property name="patxt" type="string">
      <column name="PAtxt"/>
    </property>
  </class>
</hibernate-mapping>

My question is that how do I map <bag> of parameters in the section.hbm.xml when I don't want to use section-table's primary key? I tried <key property-ref=""> but then I only could use one column. I need to use two columns (SElang=PAlang and PAsetyid=SEtyid)! This would be easy to solve with plain SQL but i don't know how to do this with hibernate.

I hope you can understand my confusing post!

Any help would be greatly appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 06, 2006 8:56 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
Joel,

try with formula

Best


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