Giter Site home page Giter Site logo

Comments (2)

mp911de avatar mp911de commented on June 21, 2024

Persistable is a Spring Data API to determine the identifier and whether an object is new or not. Persistable is only used by Spring Data modules in which we fully control the object lifecycle such as Elasticsearch.

JPA handles object lifecycles on its own with the concept of attached entities hence Spring Data JPA doesn't make use of Persistable for inserts vs. updates, instead, what you already found, whether to call EntityManager.merge(…) vs. EntityManager.persist(…).

Generally speaking, if you use a single cache (Cache.cacheMap.get(md5)) for two persistence technologies, after associating the object with your cache, all related store modules will use the same outcome for isNew.

Ideally, you use the md5 value as primary key if that is what you're looking for.

from spring-data-jpa.

lyworry avatar lyworry commented on June 21, 2024

Persistable seem to be unuseful in spring data jpa.All operations depend on whether id has value.I can't imagine what can i do with Persistable .I think spring data jpa and spring data elasticsearch,they all belong to spring data,
they implements Persistable,They should have the same behavior

  1. if document ’s id has value and isNew=true will throw exception, isNew=false will select by id and update;
  2. if document ’s id is null and isNew=true will insert,isNew=false wll also insert;

from spring-data-jpa.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.