-->
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.  [ 6 posts ] 
Author Message
 Post subject: Hibernate vs xml vs collection
PostPosted: Thu Feb 03, 2005 9:33 am 
Beginner
Beginner

Joined: Fri Jan 07, 2005 2:47 pm
Posts: 45
My question:

I am still in the learning curve regarding Hibernate including Java. So please your help would be wonderful.

Assuming that you receive a collection, a list or the type doesn’t matter if that contains more than one element. So think about followupid = “OK1_1”, “OK1_2”…
Observation = “Good”, “Ok”, “Bad”…. And status = “I”
To have a better understanding I also included my class below. How can I map the followup xml file to be able to insert all elements of my collection in one call? Can hibernate do that or do I have to insert the element by calling hibernate for each element through a loop from the business object?

Thanks in advance for your output.

My class :

import java.util.Collection;
import SAP.Utility.InfrastructureException;
import SAP.DAOObjects.FollowupDAO;
import net.sf.hibernate.*;
//import java.util.HashSet;
import java.util.*;

public class Followup {
private Set followupid = new HashSet();
Here I tried different type of collection one at the time without success.
private List observation = new ArrayList();
private String status;
private FollowupDAO followupDAO = new FollowupDAO();

//Constructor
public Followup(){}

public Set getFollowupid() {
return followupid;
}
public void setFollowupid(Set followupid) {
this.followupid = followupid;
}
public List getObservation() {
return observation;
}
public String getStatus() {
return status;
}
public void setObservation(List observation) {
this.observation = observation;
}
public void setStatus(String status) {
this.status = status;
}




Hibernate version:
Hibernate 2.1.6

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

<hibernate-mapping >

<class name="SAP.BusinessObjects.Followup"
table="X_FOLLOWUPS">

<id name="followupid"
type="java.lang.String"
column="FOLLOWUP_ID"
length="30">
<generator class="assigned"/>

</id>

<property name="observation"
type="java.lang.String"
length="2000"
column="FOLLOWUP_OBSERVATIONS"
update="true"
insert="true"/>

<property name="status"
type="java.lang.String"
length="1"
column="FOLLOWUP_STATUS"
update="true"
insert="true"/>

</class>

</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
//Constructor
public FollowupDAO(){
HibernateUtil.beginTransaction();
}
public void Create(Object obj) throws HibernateException
{
super.create(obj);
HibernateUtil.commitTransaction();
HibernateUtil.closeSession();
}


Full stack trace of any exception that occurs:
None. The insert working fine if I save the data without using a collection. So for normal saving activity everything is ok.
Name and version of the database you are using:
Oracle 9
The generated SQL (show_sql=true):
I never get to that level when I am trying to set the mapping file to be able to save a collection using set or a list.
Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 03, 2005 2:39 pm 
Beginner
Beginner

Joined: Fri Jan 07, 2005 2:47 pm
Posts: 45
Why can't I get an answer??? please. Is my question stupid????


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 03, 2005 6:57 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
i have a hard time understanding your question.

either its really trivial (which i assume) and thus it is documented in the ref docs and even the tutorials.

if its more complex (and i doubt that) you would need to rephrase the question....i especially dont understand the subject....

p.s. expecting to get an answer within 4 hours on a high load forum sounds kinda urgent for you - have you considered commercial support ?

-max

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Hibernate vs xml vs collection
PostPosted: Tue Feb 08, 2005 8:52 am 
Beginner
Beginner

Joined: Fri Jan 07, 2005 2:47 pm
Posts: 45
All hibernate tutorials and books talked and gave exemple on how to map a collection by set, map, bag and list with a normalize database. Unfortunately I have to deal with a none-normalize database and that causing me a lot of problem.

So my question was I have a class that contain three element the id, observation and status. So the class itself is a collection. How can I map those three element so hibernate know that it has to insert the first three element and the second three element information and so on?

Hopefully my question is clearer then before thanks you very much.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 11, 2005 8:19 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
sorry - still dont understand.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Hibernate vs xml vs collection
PostPosted: Fri Feb 11, 2005 9:33 am 
Beginner
Beginner

Joined: Fri Jan 07, 2005 2:47 pm
Posts: 45
The problem is because we have to work with a none-normalize tables and it's hard to explain and as well to understand. However we found a solution to our problem by wrapping the objects to simulate normalize tables used to display the data and bring back the data in his original format.

Works very well.

Thank you very much.


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