-->
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: Mapping problem
PostPosted: Tue Jul 20, 2004 5:37 am 
Newbie

Joined: Tue Jul 20, 2004 5:15 am
Posts: 5
Hi,

I'm experimenting a bit with hibernate at the moment and a simple problem occured, my class PaymentSummary contains

Code:
public class Payment {
   private Long paymentId;
   private ValueDate creditValueDate;
   private ValueDate debitValueDate;

   public Payment() {
   }

   public Long getPaymentId() {
      return paymentId;
   }

   public ValueDate getCreditValueDate() {
      return creditValueDate;
   }

   public ValueDate getDebitValueDate() {
      return debitValueDate;
   }

   public void setPaymentId(Long paymentId) {
      this.paymentId = paymentId;
   }

   public void setCreditValueDate(ValueDate date) {
      creditValueDate = date;
   }

   public void setDebditValueDate(ValueDate date) {
      debitValueDate = date;
   }
}

AND

Code:
public class ValueDate {
   private Long valueDateId = null;
   private Date date = null;
   private String tag = null;

   public ValueDate() {
   }

   public Long getValueDateId() {
      return valueDateId;
   }

   public void setValueDateId(Long long1) {
      valueDateId = long1;
   }
   
   public Date getDate(){
      return date;
   }

   public void setDate(Date date) {
      this.date = date;
   }
   
   public String getTag() {
      return tag;
   }

   public void setTag(String tag) {
      this.tag = tag;
   }
}


What would the mapping of Payment look like? I don't succeed in storing the creditValueDate and debitValueDate.

The mapping of ValueDate would look like:
Code:
<?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>
   <class name="eg.ValueDate" table="VALUEDATE">
      <id name="valueDateId" column="valueDateId" type="long">
         <generator class="increment"/>
      </id>
      <property name="date" type="date"/>
      <property name="tag" type="string"/>
   </class>
</hibernate-mapping>


I tried to let hibernate "autodetect" the type of properties creditValueDate and debitValueDate. I've put the type hardcode, but none of those work.

Then I've tried to put a one-to-one for each of the properties, but that also doesn't work correctly (key problem).

How should I do this nicely?

Kind regards
B


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 20, 2004 5:42 am 
Regular
Regular

Joined: Mon Oct 06, 2003 1:59 am
Posts: 52
How do you want to get it mapped?

one-to-one means that the reffered object must have the same primary key as the source objects.

See the documenation of one-to-one (Basic Mapping).

Hope that helps.
[/quote]

_________________
"Wisest of the Maia was Ol


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 20, 2004 5:46 am 
Newbie

Joined: Tue Jul 20, 2004 5:15 am
Posts: 5
That is why i didn't work correctly :-) for my needs.

I also tried to map it via the component tag, but then Hibernate complains.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 20, 2004 5:48 am 
Newbie

Joined: Tue Jul 20, 2004 5:15 am
Posts: 5
brucie wrote:
That is why i didn't work correctly :-) for my needs.

I also tried to map it via the component tag, but then Hibernate complains.

I just want to store creditValueDate debitValueDate in a nice way and I prefer that valueDates are in a seperate table.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 20, 2004 9:15 am 
Newbie

Joined: Tue Jul 20, 2004 5:15 am
Posts: 5
Looks like this topic as analogues, but no answer.
http://forum.hibernate.org/viewtopic.ph ... alue+types


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 20, 2004 9:32 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
The mapping of valuedate is useless. show the mapping of payment and look at the property-ref attribute of one to one.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 22, 2004 2:36 am 
Newbie

Joined: Tue Jul 20, 2004 5:15 am
Posts: 5
michael wrote:
The mapping of valuedate is useless. show the mapping of payment and look at the property-ref attribute of one to one.


Sorry, but I can't find anything about the "property-ref attribute of one to one" in the reference document. Where can I find this info?


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.