Hello all,
Has anyone had any success with using the Hibernate specific annotation of @SQLDelete in a Spring Roo entity?
I want to implement soft delete but have not had much success. Ideally, I'd like to be able to do this from a mapped superclass. But I need to get this working first.
I'm using:
STS 2.8
Spring Roo 1.2M1
Spring MVC 3
JPA with Hibernate as my provider
MariaDB 5.3.x
Found this information
http://featurenotbug.com/2009/07/soft-deletes-using-hibernate-annotations/ though it is a bit dated.
I first tried it as the above link suggests and I place the @SQLDelete in my concrete entity class that extends, a mapped super class and I receive the following error:
Code:
ERROR org.hibernate.util.JDBCExceptionReporter - Parameter index out of range (2 > number of parameters, which is 1).
I'm not sure why I am getting this so I decided to experiment.
During my experimentation, I created a base entity class called EntityBase as a mapped superclass. I then created a "Person" mapped superclass that extends EntityBase. I create a concrete entity that extends Person.
I put the @SQLDelete command in the EntityBase thinking that every class that extends EntityBase would then override the default hibernate/JPA delete method.
So Entity base now looks like this.
Code:
@MappedSuperclass
@Configurable
@RooJavaBean
@RooToString
@RooEntity(mappedSuperclass = true)
@SQLDelete(sql="UPDATE entitybase SET active = 0 WHERE id = ?")
public class EntityBase { ...
... }
When I debug through the code, it no longer throws the error I mentioned above, but instead of actually running the SQL I have in the @SQLDelete the normal JPA remove method is called. Is it possible to use @SQLDelete on a mapped superclass?
Is it possible to use @SQLDelete in a mapped super class? If not can I use it on a class that extends a mapped superclass?
I've looked around and I can't really find out any really good detailed information.
Any help or guidance on this would be greatly appreciated.
Thanks!
John