-->
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.  [ 2 posts ] 
Author Message
 Post subject: Date, Calendar, TimeStamp, ...
PostPosted: Tue Feb 06, 2007 3:37 pm 
Newbie

Joined: Thu May 18, 2006 7:38 am
Posts: 10
Hallo!

Ich dürfte ziemlich neben mir stehen ...

Ich möchte bei einer Klasse die zwei typischen Felder "created" und "changed" als Datum/Zeit-Felder mitführen.

- created soll einmal - beim erstellen - gesetzt werden
- changed bei jedem update, aber nicht mittels "version"

Wie löst ihr das mittels Hibernate und Java.

Marco


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 06, 2007 4:35 pm 
Regular
Regular

Joined: Tue Jan 03, 2006 9:20 am
Posts: 74
creationTime wird im Constructor initialisiert, die Setter ist privat.
updateTime am konnte mit einem database trigger geaendert werden, oder im jede Setter fuer die Class.

z.b.

Code:
Date creationDate;
Date updateDate;

public AnObject() {
    creationDate = new Date();
}

private setCreationDate(Date date) { }
public getCreationDate() { return creationDate;}

private setUpdateDate(Date date) {}

public setAnotherProperty(Object anotherProperty) {
   this.anotherProperty = anotherProperty;
   updateDate = new Date();
}


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