Questions tagged [persist]

502 questions
992
votes
15 answers

JPA EntityManager: Why use persist() over merge()?

EntityManager.merge() can insert new objects and update existing ones. Why would one want to use persist() (which can only create new objects)?
Aaron Digulla
  • 297,790
  • 101
  • 558
  • 777
268
votes
19 answers

PersistentObjectException: detached entity passed to persist thrown by JPA and Hibernate

I have a JPA-persisted object model that contains a many-to-one relationship: an Account has many Transactions. A Transaction has one Account. Here's a snippet of the code: @Entity public class Transaction { @Id @GeneratedValue(strategy =…
Paul Sanwald
  • 9,766
  • 4
  • 38
  • 58
71
votes
11 answers

Finding image type from NSData or UIImage

I am loading an image from a URL provided by a third-party. There is no file extension (or filename for that matter) on the URL (as it is an obscured URL). I can take the data from this (in the form of NSData) and load it into a UIImage and display…
pschang
  • 2,488
  • 3
  • 27
  • 23
71
votes
11 answers

Any way to pre populate core data?

I've been creating a list app and backing it with core data. I would like to have a default list of say 10 airport's items, so that the user doesn't have to start from scratch. Is there any way to do this? Any help is appreciated. Thanks in…
Tanner
  • 793
  • 1
  • 6
  • 12
68
votes
3 answers

JPA merge vs. persist

So far, my preference has been to always use EntityManager's merge() take care of both insert and update. But I have also noticed that merge performs an additional select queries before update/insert to ensure record does not already exists in the…
phewataal
  • 1,067
  • 3
  • 12
  • 20
35
votes
10 answers

AngularJS: Change hash and route without completely reloading controller

I have a controller, with a route like this: #/articles/1234 I want to change the route without completely reloading the controller, so I can keep the position of other stuff in the controller constant (lists that scroll) I can think of a few ways…
doubledriscoll
  • 1,159
  • 3
  • 12
  • 21
32
votes
3 answers

Spring-Data JPA: save new entity referencing existing one

The question is basically the same as below one: JPA cascade persist and references to detached entities throws PersistentObjectException. Why? I'm creating a new entity that references an existing, detached one. Now when I save this entity in my…
beginner_
  • 6,371
  • 18
  • 60
  • 112
25
votes
3 answers

Spark: Difference between Shuffle Write, Shuffle spill (memory), Shuffle spill (disk)?

I have the following spark job, trying to keep everything in memory: val myOutRDD = myInRDD.flatMap { fp => val tuple2List: ListBuffer[(String, myClass)] = ListBuffer() : tuple2List }.persist(StorageLevel.MEMORY_ONLY).reduceByKey { (p1,…
Edamame
  • 17,408
  • 44
  • 143
  • 254
19
votes
3 answers

How to persist objects between requests in PHP

I've been using rails, merb, django and asp.net mvc applications in the past. What they have common (that is relevant to the question) is that they have code that sets up the framework. This usually means creating objects and state that is persisted…
SztupY
  • 9,608
  • 8
  • 63
  • 80
18
votes
3 answers

How to persist an Array List of type Entity in JPA

How to persist an Array List of type Entity in JPA ? For example, there is an entity called "Table". I am creating an array list ArrayList table = new ArrayList
(); Trying to persist it using entityManager.persist(table); and it did not…
user1855852
  • 181
  • 1
  • 1
  • 3
17
votes
6 answers

Doctrine2 - Get entity ID before flush

Is there any way to get an entity ID before the persist/flush? I mean: $entity = new PointData(); $form = $this->createForm(new PointDataType(), $entity); If I try $entity->getId() at this point, it returns nothing. I can get it working…
Xavi
  • 1,475
  • 2
  • 13
  • 15
13
votes
1 answer

JPA - saving changes without persist() invoked

We are using Toplink implementation of JPA + Spring + EJB. In one of our EJBs we have something like this: public void updateUser(long userId, String newName){ User u = em.get(User.class, userId); u.setName(newName); // no persist is…
anthony
  • 233
  • 2
  • 10
12
votes
2 answers

[RN][Redux-Persist] AutoRehydrate is not a function

I am using redux-persist 5.5.0 When I debug my react native app, Error say "autoRehydrate is not a function" my source code here, give me help please "use strict"; import thunk from "redux-thunk"; import analytics from "./analytics"; import array…
JaeWang Lee
  • 187
  • 1
  • 10
12
votes
2 answers

Stop Hibernate from updating collections when they have not changed

I have two entity beans defined as follows (unrelated stuff removed): @Entity @Table(...) public class MasterItem implements java.io.Serializable { private Set criticalItemses = new HashSet(0); @OneToMany(fetch =…
Gordon
  • 1,160
  • 5
  • 15
  • 22
11
votes
1 answer

Spark: persist and repartition order

I have the following code: val data = input.map{... }.persist(StorageLevel.MEMORY_ONLY_SER).repartition(2000) I am wondering what's the difference if I do the repartition first like: val data = input.map{...…
Edamame
  • 17,408
  • 44
  • 143
  • 254
1
2 3
33 34