Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Spring
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Spring
Spring Data JPA
Niall Loughnane
Ranch Hand
Posts: 209
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Hi,
i am integrating Spring Data JPA into a project but have come across an issue,
In org.springframework.data.repository.CrudRepository there is a method "save",
but when the method "save" is called i need to set 2 date fields on the object that is being saved,
is this possible in Spring Data JPA?
Thanks,
Niall
Petri Kainulainen
Greenhorn
Posts: 2
I like...
posted 11 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
You can use the entity callback methods for this purpose. The Hibernate reference documentation has a good
description about this
. In your case, your entity class would look like this:
@Entity @Table(name="examples") public class Example { //add properties here public Example() { } //This method is called before an object is persisted. You can set the dates here before the object is persisted. @PrePersist public void prePersist() { } //This method is called before an object is updated. You might not need this but this is a clean way to update modification time if you need to do this. @PreUpdate public void preUpdate() { } }
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
which technology
Newbie Question--Hibernate will not persist
XML name space error in Spring data JPA hibernate applicationContext.xml
Webpage not opening in eclipse
Spring, JPA and Albert Einstein
More...