-->
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.  [ 4 posts ] 
Author Message
 Post subject: Verifying Property Changes
PostPosted: Thu Sep 16, 2004 11:44 am 
Newbie

Joined: Thu Sep 16, 2004 11:21 am
Posts: 3
Hibernate version: 2.1.4

I want to verify the changes made to the properties of a bean.
Consider this Class:

public class Test {

private String tes1;
private String tes2;

public String getTest1() {
return test1;
}
public void setTest1(String tes1) {
this.test1 = test1
}
public String getTest2() {
return test2;
}
public void setTest2(String tes2) {
this.test2 = test2
}
}

---
The valid states for a bean of this class are:
State1: tes1 = "1";test2 = "1"
and
State2: tes1 = "1";test2 = "2"
and
State3: tes1 = "2";test2 = "1"
and
State4: tes1 = "2";test2 = "2"
---
Possible state changes:
State1 to State2;
State2 to State3;
State3 to State4;
State4 to State5;

---
I want to verify the consistency and state changes of a bean.
---
To verify if the bean has a valid state i

_________________
--
Esdras Amorim
--


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 16, 2004 3:40 pm 
Proxool Developer
Proxool Developer

Joined: Tue Aug 26, 2003 10:42 am
Posts: 373
Location: Belgium
How is Hibernate involved in this issue? Can you elaborate a bit more?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 20, 2004 5:43 pm 
Newbie

Joined: Thu Sep 16, 2004 11:21 am
Posts: 3
let me explain ... My doubt is how I can acess a bean database state before saving it?
---
Ex:
....
Session session1 = ...
...
Car car = (Car) session1.get(Car.class,"1");
...
session1.close();
....
car.setColor("blue");
...
Session session2 = ...

/*In this moment i want to retrieve the car "1" from the database to compare the values from the database register and the object "car".
Then i do ...
*/

Car car2 = (Car) session2.get(Car.class,"1");
car1.verifyChanges(car2);

session2.update(car1);
/*When i call this method i receive a NonUniqueObjectIdetifier.*/

How can i compare the values from the persistent bean and the deatached bean and after that update or save the deatached object?

Ps.
If you know a better solution for verifying the bean state changes please tell me.
It's like a database constraint verification that depends on the old register value and the new register value.
----


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 20, 2004 6:25 pm 
Proxool Developer
Proxool Developer

Joined: Tue Aug 26, 2003 10:42 am
Posts: 373
Location: Belgium
I don't think this problem is related to Hibernate at all - except you want the verification to be made before commit to the DB.

You have exactly the same problem when validating the fields of a screen form. The validation can only be done when the user explicitly says it has entered all the values (press submit). At this time, you have the state2 and you can compare it with state1 - provided you took a copy of the previous state (or recorded the property changes).

You should do the same with your application - and unfortunaly Hibernate won't help you that much on this issue...


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