I use autoincrement, but I had already some sample data in the db. So you
were right, the rollback doesn't really work. I don't know exactly why.
For the tests I'm now using the code below, like that you are sure to update
the right row and just the second one.
public void testSaveResident() th
did you use autoincrement for your ids?
/**
* Getter for Id.
* @return Id
* @hibernate.id column="id" generator-class="increment" unsaved-
value="null"
*/
public Long getId() {
return id;
}
On Jan 12, 2007, at 4:31 PM, Stefan Malär wrot
For me worked:
public void testSavePerson() throws Exception {
person = new Person();
person.setFirstName("Stefan");
person.setLastName("Malaer");
dao.savePerson(person);
person = dao.getPerson(new Long(1));
person.setFirstName("Ste
it seems so! so i did create new resident but, but auto inkrement
gives the new resident id=2 not 1! i checked this.. so there is some
inconsistency in the tutorial and the way it really works i think!?
isn't resident/person createt in test1 with id=1 removed after the
rollback of the test
Hi Bernd
Most likely the error occurs because you trying to do something like
resident = dao.getResident(new Long(1));
in your testSaveResident method. But there is no Resident in your dao
object.
Instead you have to create a Resident to be saved by writing
resident = new Resident();
Hope that
well now i get another error :-(
tests 1 and 3 run successful , but 2 ( testSaveResident in my case)
fails when retrieving object with identifier 1
the class is called Resident and getResident() works in test 1 and 3,
but fails in test 2!
OUTPUT:
test-dao:
[echo] Testing dao...
[