Results 1 to 4 of 4

Thread: Spring Roo and Hibernate @SQLDelete

  1. #1
    Join Date
    Aug 2011
    Location
    Williamsport, PA
    Posts
    29

    Default Spring Roo and Hibernate @SQLDelete

    Hello all,

    Has anyone had any success with using the Hibernate specific annotation of @SQLDelete in a 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
    • Roo 1.2M1
    • JPA with Hibernate as my provider
    • MariaDB



    Found this information HERE though it is a bit dated.


    Code:
    ...
    @SQLDelete(sql="UPDATE client SET active = (0) WHERE id = ?")
    public class Client extends Person { 
    ...
    Upon attempting to delete from my app, I'm getting the following error in the STS console.

    Code:
     ERROR org.hibernate.util.JDBCExceptionReporter - Parameter index out of range (2 > number of parameters, which is 1).
    A point in the right direction would be most appreciated.

    Thanks!

  2. #2
    Join Date
    Sep 2011
    Posts
    25

    Default Why the brackets?

    Just wondering - why are there brackets round the zero?

    I would have thought that "SET active = (0)" should be "SET active = 0"

  3. #3
    Join Date
    Aug 2011
    Location
    Williamsport, PA
    Posts
    29

    Default

    I originally had it without the parens. I did see another example that had the parens. Basically, I was to the point of "Oh well, can't do any harm, except for blow up." ;-)

  4. #4
    Join Date
    Aug 2011
    Location
    Williamsport, PA
    Posts
    29

    Default

    Hi all,

    I'm still working on my soft delete issue with @SQLDelete. I've changed things up a bit in hopes that a little experimentation would yield some sort of result.

    Here is what I've found so far.

    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 Entity base 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?

    Does anyone have any idea what I could be doing wrong?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •