-->
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.  [ 3 posts ] 
Author Message
 Post subject: As400 and Cobol
PostPosted: Mon Jun 26, 2006 8:47 am 
Newbie

Joined: Wed Oct 08, 2003 6:19 am
Posts: 9
Hello, i'm using hibernate over As400.
Before i started writing my application there was an already existing application written in Cobol that use blank string instead of null.

ex:
Code:
id     name           firstColor        secondColor
1      Mercedes       1                    null
2      Rover          1                    2


id     name
1      yellow
2      red
3      green
...



If i have no assocation in field secondColor i should write null, but cobol can't manage this and i have to write a blank string.
I don't know how cobol run and i'm looking for a workaround


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 27, 2006 2:06 am 
Regular
Regular

Joined: Tue May 16, 2006 3:32 am
Posts: 117
Add code in get/set methods of secondColor to handle this. If the access mode is "property" which is the default, Hibernate will call the get/set methods.

Code:

String secondColor;

public String getSecondColor() {
  if (secondColor == null) {
     return " ";
  }
   return secondColor;
}


public void setSecondColor(String secondColor) {
  this.secondColor = secondColor;
  if (" ".equals(secondColor))    {
     this.secondColor = null;  // when object is retrieved from database set null back
  }
}

public String getSndColor() {
  return secondColor;
}

public void setSndColor(String secondColor) {
   this.secondColor = secondColor;
}




The other set of get/set methods for SecondColor is for use by the application if you want to use null instead of blank String, otherwise it is not needed.

This is just a sample code to give you an idea.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 28, 2006 10:57 am 
Newbie

Joined: Wed Oct 08, 2003 6:19 am
Posts: 9
now it works.

Code:
<class name="Xxx" table="XXX" dynamic-insert="true" dynamic-update="true">

<many-to-one name="yyy" class="Yyy" not-found="ignore">

</class>


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