persist

Spring-Data JPA: save new entity referencing existing one

柔情痞子 提交于 2019-11-28 17:51:14
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 spring data repository an exception is thrown: org.springframework.dao.InvalidDataAccessApiUsageException: detached entity passed to persist if we look at the save() method in source code of spring data JPA we see: public <S extends T> S save(S entity) { if (entityInformation.isNew(entity)) { em.persist(entity); return entity; } else { return em.merge

How do you store data from NSMutable Array in Core Data?

人盡茶涼 提交于 2019-11-28 04:05:44
问题 The app i'm making draws a Polyline based on the users coordinates from CLLocationManager (these are all kept in an NSMutableArray ) When the app closes, the current polyline disappears. How can I store the array of points in CoreData to be retrieved when the app starts up? All of the past 'routes' that the user has taken since initiating the app should be recovered and overlaid on the map (which may be quite a lot, so CoreData seems the best option from what i've gathered). This is the code

AngularJS: Change hash and route without completely reloading controller

限于喜欢 提交于 2019-11-28 03:56:56
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 to do this, but they're all pretty ugly. Is there a best practice for doing something like this? I tried experimenting with reloadOnSearch: false, but it doesn't seem to change anything. Jens X Augustsson Had the very same challange, Found a hack in another StackOverflow response that did the trick Fairly clean solution - all I did was to add these

jqgrid retain filter on reload

ぃ、小莉子 提交于 2019-11-28 01:38:12
问题 This question has been as a lot so please forgive me asking again. I have a grid loaded from a url. I use loadonce: true I use filtertoolbar: $("#status").jqGrid('filterToolbar', { stringResult:true, searchOnEnter:false, autosearch: true, defaultSearch: "cn" }); I have a dropdown search list from which I can select what I'm looking for. Works great. I have a navbutton I click to initiate a reload every 30 seconds. Works great. $("#status").jqGrid('navButtonAdd','#statuspager', { caption: '',

How to persist objects between requests in PHP

為{幸葍}努か 提交于 2019-11-27 17:29:16
问题 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 until the web server is recycled (like setting up routing, or checking which controllers are available, etc). As far as I know PHP is more like a CGI script that gets compiled to some bytecode each time it's run, and after the request it's

JPA - saving changes without persist() invoked

≯℡__Kan透↙ 提交于 2019-11-27 16:21:54
问题 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 invoked here } So, basically this updateUser() method is supposed to update the name of a user with the given userId . But the author of this method forgot to invoke em.persist(u) . And the strangest thing is that it works fine. How can it be? I was 100% sure

Spring-Data JPA: save new entity referencing existing one

倖福魔咒の 提交于 2019-11-27 11:03:48
问题 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 spring data repository an exception is thrown: org.springframework.dao.InvalidDataAccessApiUsageException: detached entity passed to persist if we look at the save() method in source code of spring data JPA we see: public <S extends T> S save(S

AngularJS: Change hash and route without completely reloading controller

时光总嘲笑我的痴心妄想 提交于 2019-11-27 00:14:24
问题 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 to do this, but they're all pretty ugly. Is there a best practice for doing something like this? I tried experimenting with reloadOnSearch: false, but it doesn't seem to change anything. 回答1: Had the very same challange, Found a hack in another

Finding image type from NSData or UIImage

不羁岁月 提交于 2019-11-26 15:41:34
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 it fine. I want to persist this data to a file. However, I don't know what format the data is in (PNG, JPG, BMP)? I assume it is JPG (since it's an image from the web) but is there a programmatic way of finding out for sure? I've looked around StackOverflow and at the documentation and haven't been able to find anything. TIA. Edit: Do I really need

Finding image type from NSData or UIImage

放肆的年华 提交于 2019-11-26 04:32:53
问题 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 it fine. I want to persist this data to a file. However, I don\'t know what format the data is in (PNG, JPG, BMP)? I assume it is JPG (since it\'s an image from the web) but is there a programmatic way of finding out for sure? I\'ve looked around