Results 1 to 4 of 4

Thread: Issue with Spring data JPA and Spring data rest

  1. #1
    Join Date
    Jul 2012
    Location
    St. Louis, Missouri
    Posts
    15

    Default Issue with Spring data JPA and Spring data rest

    Hello,

    I'm using Spring data JPA, Spring data rest and created one entity and repository by following the tutorial.

    Is there any way to block the crud operations?

    For example, Using beforeDelete I am able to block the DELETE operation but getting the unexpected error code as "500 validation error" sometimes getting "500 Internal server error".

    I want the error message to be displayed as "405 Method not allowed"

    Can anyone help with any ideas. Thanks

  2. #2
    Join Date
    Jul 2006
    Location
    Lamar, Missouri USA
    Posts
    36

    Default

    There is already an attribute on the @RestResource annotation to disable a method. In the latest RC, that only affects query methods. If you want to create an issue in JIRA [1] for it, I can extend that switch to any crud methods as well.

    You'd just override that method in your own repository interface and add @RestResource(exported=false) to it:

    Code:
    public interface MyEntityRepository extends CrudRepository<MyEntity,Long> {
    
      @RestResource(exported = false)
      @Override public void delete(Long id);
    
    }
    Right now the controller doesn't check for this annotation on crud methods, but it would be relatively easy to add. I can also create an issue if you don't want to. Just let me know so we don't have duplicates...

    [1] - https://jira.springsource.org/browse/DATAREST
    Jon Brisbin
    SpringSource
    http://www.springsource.com

  3. #3
    Join Date
    Jul 2006
    Location
    Lamar, Missouri USA
    Posts
    36

    Default

    Oops. I see you've created an issue on Github. That should work fine. Disregard what I said earlier about JIRA.
    Jon Brisbin
    SpringSource
    http://www.springsource.com

  4. #4
    Join Date
    Jul 2012
    Location
    St. Louis, Missouri
    Posts
    15

    Default

    Thank you Jon for your reply and for identifying the issue in Github.



    Quote Originally Posted by Jon Brisbin View Post
    Oops. I see you've created an issue on Github. That should work fine. Disregard what I said earlier about JIRA.

Posting Permissions

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