Bug 138122

Summary: Modified/created dates aren't being refreshed on Address object
Product: Red Hat Network Reporter: Mike McCune <mmccune>
Component: RHN/R&DAssignee: Mike McCune <mmccune>
Status: CLOSED CURRENTRELEASE QA Contact: Red Hat Satellite QA List <satellite-qa-list>
Severity: medium Docs Contact:
Priority: medium    
Version: RHN Devel   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-12-03 18:11:18 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Bug Depends On:    
Bug Blocks: 125080    

Description Mike McCune 2004-11-04 20:29:05 UTC
When saving a User with new Addresses added to it the modified dates
are updated in the DB by a trigger.  Hibernate doesn't re-fetch the
object from the DB so these fields remain NULL.

See email below for full desc:

Working on fixing a problem where we have a test that makes sure that
the order of the Addresses on a User is returned in the most recently
modified order.

So I do the following:

        User usr = createUserInternal(userName);
        Long orgId = createOrg(orgName);
        Address addr1 = createTestAddress(usr);
        usr = UserFactory.commitNewUser(usr, addr1, orgId);
        Address addr2 = createTestAddress(usr);
        // Add a 2nd address to the User
        usr.addAddress(addr2);
        UserFactory.commit(usr);

That is all well and good.  We store the new Address on the User.

What doesn't occur is the updating of the Modified field on the
Address because its updated by a trigger in the DB.  This field
remains NULL for the lifecycle of the Address object.

So I go to HIA and find page 339.  I groan, ugh, have to refetch from
the DB (see page for what I mean).

I put a session.refresh(user) in UserFactory.commit() to see if it
will refetch the User.  It does ( I watch the SQL output from
Hibernate), but for some reason the modified field on the Address
object still remains null.

My next thoughts were to hand-code some solution to this problem with
just the modified date (set it myself when we create a new Address
object).  But, I'd prefer to rely on Hibernate for this.

Anyone have any thoughts on this?  I've burned a bunch of time and
figured I'd throw it out to the group.

Heading out to an appointment, will be online later tonight.
Mike