persistence

JPA property java.net.URL

别等时光非礼了梦想. 提交于 2019-11-27 17:47:32
问题 HI, I have an object which has a piece of URL-Information associated with it. Currently I save this URL in a simple String property, but java.net.URL would provide me with additional goodies such as detection of malformed URLs etc. On the other hand I would consider it very ugly, if JPA simply created a LOB for the URL-Object. Does anyone know how a property of the type java.net.URL will be persisted to the database by compliant JPA providers? 回答1: As per the JPA spec: The persistent fields or

A RESTful persistence solution usable with backbone.js… in PHP?

旧街凉风 提交于 2019-11-27 17:32:38
I'll preface this with saying that I'm a crappy programmer, I'm sure that what I want to do could be done in 10 lines of node or Rails or something else, but PHP is what I have available. So, I'm hoping to find a simple PHP library which wraps the database calls in an API that looks similar to the RESTful model. I've had little success trying to find such a thing -- searching for PHP CRUD or PHP REST turns up several zillion pages, and I've no idea how to filter through them. I'm really trying to keep things simple here, I don't want a big framework like Zend or something. The models I'm

Passing empty list as parameter to JPA query throws error

坚强是说给别人听的谎言 提交于 2019-11-27 17:11:18
问题 If I pass an empty list into a JPA query, I get an error. For example: List<Municipality> municipalities = myDao.findAll(); // returns empty list em.createQuery("SELECT p FROM Profile p JOIN p.municipality m WHERE m IN (:municipalities)") .setParameter("municipalities", municipalities) .getResultList(); Because the list is empty, Hibernate generates this in SQL as "IN ()", which gives me error with Hypersonic database. There is a ticket for this in Hibernate issue tracking but there are not

Wipe all data stored with CoreData when the model has changed

China☆狼群 提交于 2019-11-27 16:27:03
问题 I have an app that fetches data from the internet and uses CoreData to store them in the device, for a smoother experience. Because I use Core Data, every time my schema changes, the app crashes when I try to run it with the previous data stored on the device. What is the fastest way to detect this change and wipe all the data from the device, since I don't mind redownloading them all. It beats crashing and remapping the schema to the new one (in my case). I see that this check is performed

How to make offline database for my app?

喜夏-厌秋 提交于 2019-11-27 14:55:52
I am getting problem in consuming RestAPI and saving offline data. Is any one have best ideas about this. I want to save JSON response from server in local database and use that data when no internet is available. like Firebase realtime Database. I think what are you asking for is a mechanism to persist data into your application. There are several approaches to achieve this. Although it could be too broad to provide detailed answer, you might want to check as options: Databases: Core Data : Core Data is an object graph and persistence framework provided by Apple in the macOS and iOS operating

How to use JDO persistence manager?

只愿长相守 提交于 2019-11-27 14:51:49
I have two questions regarding how to create / use the JDO persistence manager (PM, hereafter). Say, in a Java web application, if I have 10 entities, which can be logically grouped into 2 groups (for example, 5 user related entities and 5 business related entities) Should I need two different PMs to manage these 2 groups or only one PM is enough? Regarding the initialization, shall I use singleton instance of a PM (which will be shared by all the user's using the app at a given point of time) or should I create a PM for each and every session? NamshubWriter According to the JDO Documentation

@JoinFormula and @OneToMany definition - poor documentation

吃可爱长大的小学妹 提交于 2019-11-27 14:25:31
问题 I have two questions concerning @JoinFormula and @OneToMany annotations: How can I limit the number of result with @JoinFormula and @OneToMany annotations? How can I define that id in expression author = id refers to Author.id ? Author { @Id private Long id; @OneToMany @JoinFormula(value = "SELECT a FROM Article a WHERE author = id AND schedule < CURRENT_TIMESTAMP()") // limit = 15 private List<Article> pastArticles; } Like this, I keep having the pastArticles empty, even when I remove the

C#: How to make a form remember its Bounds and WindowState (Taking dual monitor setups into account)

 ̄綄美尐妖づ 提交于 2019-11-27 14:05:10
问题 I have made a class which a form can inherit from and it handles form Location, Size and State. And it works nicely. Except for one thing: When you maximize the application on a different screen than your main one, the location and size (before you maximized) gets stored correctly, but when it is maximized (according to its previous state) it is maximized on my main monitor. When I then restore it to normal state, it goes to the other screen where it was before. When I then maximize it again,

Primary Key Type: int vs long

不羁岁月 提交于 2019-11-27 13:33:19
问题 I know some software shops have been burned by using the int type for the primary key of a persistent class. That being said, not all tables grow past 2 billions. As a matter of fact, most don't. So, do you guys use the long type only for those classes that are mapped to potentially large tables OR for every persistent class just to be consistent? What's the industry concensus? I'll leave this question open for a while so that you can share with us your success/horror stories. 回答1: Long can

How to load a separate Application Settings file dynamically and merge with current settings?

情到浓时终转凉″ 提交于 2019-11-27 13:20:43
There are questions pertaining to reading settings from a separate config file and others similar to it, but my question is specific to application property settings (i.e. <MyApplication.Properties.Settings> - see XML file below) and how to load them dynamically. I tried the method in this post , which involved refreshing the entire appSettings section of the main config file, but my adaptation threw exceptions because I wasn't replacing the appSettings section: var config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal); // Have tried the other