Spring JPA repo does not seem to save nor does it throws any exceptionSpring JpaRepositroy.save() does not appear to throw exception on duplicate savesWrong ordering in generated table in jpaCreate the perfect JPA entityHow to ignore unique violation during insert list of objects which contain set of objectSpring Data JPA - “No Property Found for Type” ExceptionDifference between save and saveAndFlush in Spring data jpaJava Serialization/De-serialization giving null object referencesCan someone show me a simple working implementation of PagerSlidingTabStrip?Spring Data JPA throwing exceptionHibernate : Why FetchType.LAZY-annotated collection property eagerly loading?Right way to make insertion of an entity + foreign key on database(Use : Mysql, JPA)

Why is the number of local variables used in a Java bytecode method not the most economical?

If Trump gets impeached, how long would Pence be president?

Copying an existing HTML page and use it, is that against any copyright law?

Commercial jet accompanied by small plane near Seattle

Catan Victory points

Melee or Ranged attacks by Monsters, no distinction in modifiers?

What do you call a flexible diving platform?

Why/when is AC-DC-AC conversion superior to direct AC-AC conversion?

Unethical behavior : should I report it?

Why can't my huge trees be chopped down?

Are the named pipe created by `mknod` and the FIFO created by `mkfifo` equivalent?

Examples of simultaneous independent breakthroughs

If my pay period is split between 2 calendar years, which tax year do I file them in?

Learning Minor scales through 7 patterns (Guitar)

How to store my pliers and wire cutters on my desk?

Do the books ever say oliphaunts aren’t elephants?

Seaborn style plot of pandas dataframe

How can I write an interdental lateral in phonetic transcription?

What is the difference between position, displacement, and distance traveled?

How many oliphaunts died in all of the Lord of the Rings battles?

Use cases for M-0 & C-0?

How could Nomadic scholars effectively memorize libraries worth of information

Japanese reading of an integer

The Sword in the Stone



Spring JPA repo does not seem to save nor does it throws any exception


Spring JpaRepositroy.save() does not appear to throw exception on duplicate savesWrong ordering in generated table in jpaCreate the perfect JPA entityHow to ignore unique violation during insert list of objects which contain set of objectSpring Data JPA - “No Property Found for Type” ExceptionDifference between save and saveAndFlush in Spring data jpaJava Serialization/De-serialization giving null object referencesCan someone show me a simple working implementation of PagerSlidingTabStrip?Spring Data JPA throwing exceptionHibernate : Why FetchType.LAZY-annotated collection property eagerly loading?Right way to make insertion of an entity + foreign key on database(Use : Mysql, JPA)






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I am using Spring boot 2.0.3.RELEASE(FINCHLEY) `starter-data-jpa 2.0.5.RELEASE.
The scenario is pretty basic, build an entity and save it.



Let's go through the code for better context before we go through texts.



Entity class (Asset): The id(primary key) does not generate automatically because we basically get a unique UUID.toString() from another source which is assuredly unique.



import lombok.*;
import org.springframework.data.domain.Persistable;

import javax.persistence.*;
import java.util.List;

@Setter
@Getter
@ToString
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Entity
@Table(name = "ASSET", schema = "SCHEMA")
public class Asset implements Persistable<String>
// Propriety code hence column names removed.
//Let's just assume column names are fine, since when I am doing a find(), results are cool

private static final long serialVersionUID = 1L;

@Id
private String id;

private String creditPool;

private int quantity;

private int assetStatusTypeId;

private long assetTypeId;

private int ageOfAsset;

//The below snippet is part of Persistable<String> to force a new entry. Newly added following an answer in stackoverflow.

//Here, update is basically false by default,
//so as you can see isNew() will always return true forcing jpa to save a new record

@Transient
private boolean update;

@Override
public String getId()
return this.id;


@Override
public boolean isNew()
return !this.update;




As per the comments I have added, you see I added that snippet because we are not autogenerating the id.



Without the snippet and Persistable the issue is same btw.



My custom repository class has the below custom save function because of business reasons.



@Override
public <S extends T> S save(S entity, long value)
entity.someParams(args getting from from a jar) //which is really fine
return super.save(entity);



Code from which save is being called is below



Asset asset = Asset.builder()
.id(UUID.randomId().toString()) //see always unique
.assetStatusTypeId(a valid id)
.assetTypeId(a valid id)
.creditPool("pool")
.quantity(integer value)
.ageOfAsset(integer value).build();
repo.save(asset);


I have verified the builder mutiple times and, It indeed creates a Asset object without fail.



But the culprit save never gets executed.



I have turned on the showSQL:true to check whether the insert query gets called or not. But I see no such queries.



Hibernate properties:



jpa:
show-sql: true
properties:
hibernate:
enable_lazy_load_no_trans: true
show_sql: true
format_sql: true
jdbc:
batch_size: 5


I considered a scenario where even with all the safe checks, JPA might be treating it as a update scenario,



I ignored the save and used persist as well. Even then no insertion.



repo.persist(asset);



Please help on this.



stackoverflow Sources for my workarounds and the duplicates.
Any help on this would be very much appreciated.










share|improve this question






























    0















    I am using Spring boot 2.0.3.RELEASE(FINCHLEY) `starter-data-jpa 2.0.5.RELEASE.
    The scenario is pretty basic, build an entity and save it.



    Let's go through the code for better context before we go through texts.



    Entity class (Asset): The id(primary key) does not generate automatically because we basically get a unique UUID.toString() from another source which is assuredly unique.



    import lombok.*;
    import org.springframework.data.domain.Persistable;

    import javax.persistence.*;
    import java.util.List;

    @Setter
    @Getter
    @ToString
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    @Entity
    @Table(name = "ASSET", schema = "SCHEMA")
    public class Asset implements Persistable<String>
    // Propriety code hence column names removed.
    //Let's just assume column names are fine, since when I am doing a find(), results are cool

    private static final long serialVersionUID = 1L;

    @Id
    private String id;

    private String creditPool;

    private int quantity;

    private int assetStatusTypeId;

    private long assetTypeId;

    private int ageOfAsset;

    //The below snippet is part of Persistable<String> to force a new entry. Newly added following an answer in stackoverflow.

    //Here, update is basically false by default,
    //so as you can see isNew() will always return true forcing jpa to save a new record

    @Transient
    private boolean update;

    @Override
    public String getId()
    return this.id;


    @Override
    public boolean isNew()
    return !this.update;




    As per the comments I have added, you see I added that snippet because we are not autogenerating the id.



    Without the snippet and Persistable the issue is same btw.



    My custom repository class has the below custom save function because of business reasons.



    @Override
    public <S extends T> S save(S entity, long value)
    entity.someParams(args getting from from a jar) //which is really fine
    return super.save(entity);



    Code from which save is being called is below



    Asset asset = Asset.builder()
    .id(UUID.randomId().toString()) //see always unique
    .assetStatusTypeId(a valid id)
    .assetTypeId(a valid id)
    .creditPool("pool")
    .quantity(integer value)
    .ageOfAsset(integer value).build();
    repo.save(asset);


    I have verified the builder mutiple times and, It indeed creates a Asset object without fail.



    But the culprit save never gets executed.



    I have turned on the showSQL:true to check whether the insert query gets called or not. But I see no such queries.



    Hibernate properties:



    jpa:
    show-sql: true
    properties:
    hibernate:
    enable_lazy_load_no_trans: true
    show_sql: true
    format_sql: true
    jdbc:
    batch_size: 5


    I considered a scenario where even with all the safe checks, JPA might be treating it as a update scenario,



    I ignored the save and used persist as well. Even then no insertion.



    repo.persist(asset);



    Please help on this.



    stackoverflow Sources for my workarounds and the duplicates.
    Any help on this would be very much appreciated.










    share|improve this question


























      0












      0








      0








      I am using Spring boot 2.0.3.RELEASE(FINCHLEY) `starter-data-jpa 2.0.5.RELEASE.
      The scenario is pretty basic, build an entity and save it.



      Let's go through the code for better context before we go through texts.



      Entity class (Asset): The id(primary key) does not generate automatically because we basically get a unique UUID.toString() from another source which is assuredly unique.



      import lombok.*;
      import org.springframework.data.domain.Persistable;

      import javax.persistence.*;
      import java.util.List;

      @Setter
      @Getter
      @ToString
      @Builder
      @AllArgsConstructor
      @NoArgsConstructor
      @Entity
      @Table(name = "ASSET", schema = "SCHEMA")
      public class Asset implements Persistable<String>
      // Propriety code hence column names removed.
      //Let's just assume column names are fine, since when I am doing a find(), results are cool

      private static final long serialVersionUID = 1L;

      @Id
      private String id;

      private String creditPool;

      private int quantity;

      private int assetStatusTypeId;

      private long assetTypeId;

      private int ageOfAsset;

      //The below snippet is part of Persistable<String> to force a new entry. Newly added following an answer in stackoverflow.

      //Here, update is basically false by default,
      //so as you can see isNew() will always return true forcing jpa to save a new record

      @Transient
      private boolean update;

      @Override
      public String getId()
      return this.id;


      @Override
      public boolean isNew()
      return !this.update;




      As per the comments I have added, you see I added that snippet because we are not autogenerating the id.



      Without the snippet and Persistable the issue is same btw.



      My custom repository class has the below custom save function because of business reasons.



      @Override
      public <S extends T> S save(S entity, long value)
      entity.someParams(args getting from from a jar) //which is really fine
      return super.save(entity);



      Code from which save is being called is below



      Asset asset = Asset.builder()
      .id(UUID.randomId().toString()) //see always unique
      .assetStatusTypeId(a valid id)
      .assetTypeId(a valid id)
      .creditPool("pool")
      .quantity(integer value)
      .ageOfAsset(integer value).build();
      repo.save(asset);


      I have verified the builder mutiple times and, It indeed creates a Asset object without fail.



      But the culprit save never gets executed.



      I have turned on the showSQL:true to check whether the insert query gets called or not. But I see no such queries.



      Hibernate properties:



      jpa:
      show-sql: true
      properties:
      hibernate:
      enable_lazy_load_no_trans: true
      show_sql: true
      format_sql: true
      jdbc:
      batch_size: 5


      I considered a scenario where even with all the safe checks, JPA might be treating it as a update scenario,



      I ignored the save and used persist as well. Even then no insertion.



      repo.persist(asset);



      Please help on this.



      stackoverflow Sources for my workarounds and the duplicates.
      Any help on this would be very much appreciated.










      share|improve this question
















      I am using Spring boot 2.0.3.RELEASE(FINCHLEY) `starter-data-jpa 2.0.5.RELEASE.
      The scenario is pretty basic, build an entity and save it.



      Let's go through the code for better context before we go through texts.



      Entity class (Asset): The id(primary key) does not generate automatically because we basically get a unique UUID.toString() from another source which is assuredly unique.



      import lombok.*;
      import org.springframework.data.domain.Persistable;

      import javax.persistence.*;
      import java.util.List;

      @Setter
      @Getter
      @ToString
      @Builder
      @AllArgsConstructor
      @NoArgsConstructor
      @Entity
      @Table(name = "ASSET", schema = "SCHEMA")
      public class Asset implements Persistable<String>
      // Propriety code hence column names removed.
      //Let's just assume column names are fine, since when I am doing a find(), results are cool

      private static final long serialVersionUID = 1L;

      @Id
      private String id;

      private String creditPool;

      private int quantity;

      private int assetStatusTypeId;

      private long assetTypeId;

      private int ageOfAsset;

      //The below snippet is part of Persistable<String> to force a new entry. Newly added following an answer in stackoverflow.

      //Here, update is basically false by default,
      //so as you can see isNew() will always return true forcing jpa to save a new record

      @Transient
      private boolean update;

      @Override
      public String getId()
      return this.id;


      @Override
      public boolean isNew()
      return !this.update;




      As per the comments I have added, you see I added that snippet because we are not autogenerating the id.



      Without the snippet and Persistable the issue is same btw.



      My custom repository class has the below custom save function because of business reasons.



      @Override
      public <S extends T> S save(S entity, long value)
      entity.someParams(args getting from from a jar) //which is really fine
      return super.save(entity);



      Code from which save is being called is below



      Asset asset = Asset.builder()
      .id(UUID.randomId().toString()) //see always unique
      .assetStatusTypeId(a valid id)
      .assetTypeId(a valid id)
      .creditPool("pool")
      .quantity(integer value)
      .ageOfAsset(integer value).build();
      repo.save(asset);


      I have verified the builder mutiple times and, It indeed creates a Asset object without fail.



      But the culprit save never gets executed.



      I have turned on the showSQL:true to check whether the insert query gets called or not. But I see no such queries.



      Hibernate properties:



      jpa:
      show-sql: true
      properties:
      hibernate:
      enable_lazy_load_no_trans: true
      show_sql: true
      format_sql: true
      jdbc:
      batch_size: 5


      I considered a scenario where even with all the safe checks, JPA might be treating it as a update scenario,



      I ignored the save and used persist as well. Even then no insertion.



      repo.persist(asset);



      Please help on this.



      stackoverflow Sources for my workarounds and the duplicates.
      Any help on this would be very much appreciated.







      java spring-boot spring-data-jpa






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 26 at 19:06







      bibliophilsagar

















      asked Mar 26 at 18:57









      bibliophilsagarbibliophilsagar

      1,22812 silver badges27 bronze badges




      1,22812 silver badges27 bronze badges






















          1 Answer
          1






          active

          oldest

          votes


















          0














          You should flush after the save or directly use saveAndFlush(asset).






          share|improve this answer

























          • The save does not get executed and that's the issue and you want me to to flush after saving ?

            – bibliophilsagar
            Mar 27 at 5:33











          • Save will only get executed if you flush your transaction to the DB.

            – oliver.g
            Mar 27 at 6:57










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55364459%2fspring-jpa-repo-does-not-seem-to-save-nor-does-it-throws-any-exception%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          You should flush after the save or directly use saveAndFlush(asset).






          share|improve this answer

























          • The save does not get executed and that's the issue and you want me to to flush after saving ?

            – bibliophilsagar
            Mar 27 at 5:33











          • Save will only get executed if you flush your transaction to the DB.

            – oliver.g
            Mar 27 at 6:57















          0














          You should flush after the save or directly use saveAndFlush(asset).






          share|improve this answer

























          • The save does not get executed and that's the issue and you want me to to flush after saving ?

            – bibliophilsagar
            Mar 27 at 5:33











          • Save will only get executed if you flush your transaction to the DB.

            – oliver.g
            Mar 27 at 6:57













          0












          0








          0







          You should flush after the save or directly use saveAndFlush(asset).






          share|improve this answer















          You should flush after the save or directly use saveAndFlush(asset).







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 26 at 21:48

























          answered Mar 26 at 20:29









          oliver.goliver.g

          541 silver badge5 bronze badges




          541 silver badge5 bronze badges












          • The save does not get executed and that's the issue and you want me to to flush after saving ?

            – bibliophilsagar
            Mar 27 at 5:33











          • Save will only get executed if you flush your transaction to the DB.

            – oliver.g
            Mar 27 at 6:57

















          • The save does not get executed and that's the issue and you want me to to flush after saving ?

            – bibliophilsagar
            Mar 27 at 5:33











          • Save will only get executed if you flush your transaction to the DB.

            – oliver.g
            Mar 27 at 6:57
















          The save does not get executed and that's the issue and you want me to to flush after saving ?

          – bibliophilsagar
          Mar 27 at 5:33





          The save does not get executed and that's the issue and you want me to to flush after saving ?

          – bibliophilsagar
          Mar 27 at 5:33













          Save will only get executed if you flush your transaction to the DB.

          – oliver.g
          Mar 27 at 6:57





          Save will only get executed if you flush your transaction to the DB.

          – oliver.g
          Mar 27 at 6:57








          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







          Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55364459%2fspring-jpa-repo-does-not-seem-to-save-nor-does-it-throws-any-exception%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현