persistence

How to map custom collection in JPA?

老子叫甜甜 提交于 2019-11-27 06:01:56
问题 I have problems in mapping custom collection with JPA (Hiberante provider). For example when I am using object with attribute List<Match> matches; with <one-to-many name="matches"> <cascade> <cascade-all /> </cascade> </one-to-many> in my ORM file, it is allright; But if I replace "List matches;" by private Matches matches; ,where "Matches" is defined like: public class Matches extends ArrayList<Match> { private static final long serialVersionUID = 1L; } It produces following error: Caused by

POCO's, behavior and Peristance Igorance

亡梦爱人 提交于 2019-11-27 05:29:29
From what I have read POCO classes should be persistence ignorant and should not contain references to repositories. Q1. Given the above, how would I populate the QuestionBlocks collection? I have read that POCO's should contain behavior so you don't end of with an anemic model, so I'm kind of confused as how one is supposed to do that without persistence. If that's the case then what kind of behavior would you put in a POCO? Ex: public class Survey { public int SurveyId { get; set; } public string Title { get; set; } public int BrandId { get; set; } public DateTime Created { get; set; }

@PersistenceUnit annotation won't create an EntityManageFactory emf=null

喜你入骨 提交于 2019-11-27 04:42:29
问题 I'm try to use the Sun Java PetStore Demo. In the CatalogFacade class there is the following annotation: @PersistenceUnit(unitName="myPetStorePU") private EntityManagerFactory emf; In all the methods of the CatalogFacade Sun has: EntityManager em = emf.createEntityManager(); But I am getting a null pointer exception for emf when trying to createEntityManager. But... if I add the following line above that line as such EntityManagerFactory emf = javax.persistence.Persistence

PHP - ini_set('session.gc_maxlifetime', 5) - Why it doesn't end the session?

纵然是瞬间 提交于 2019-11-27 04:25:33
问题 The PHP script is as follows: <?php // continue.php ini_set('session.gc_maxlifetime', 5); session_start(); echo ini_get('session.gc_maxlifetime'); // wait for 7 seconds usleep(7000000); if (isset($_SESSION['username'])) { $username = $_SESSION['username']; $password = $_SESSION['password']; $forename = $_SESSION['forename']; $surname = $_SESSION['surname']; echo "Welcome back $forename.<br /> Your full name is $forename $surname.<br /> Your username is '$username' and your password is '

Are there any Java VMs which can save their state to a file and then reload that state?

℡╲_俬逩灬. 提交于 2019-11-27 04:24:55
Are there any Java VMs which can save their state to a file and then reload that state? If so, which ones? Another option, which may or may not be relevant in your case, is to run the JVM (any JVM) inside a virtual machine. Most virtual machines offer the option to store and resume state, so you should be able to restart your PC, fire up the VM when it comes back up and have the Java process pick up from where it was. I use VMWare Player for testing on IE at work, and this works as noted above when I close and later reopen it. I don't generally do this when apps are doing anything of note in

Why can't environmental variables set in python persist?

我与影子孤独终老i 提交于 2019-11-27 03:38:34
I was hoping to write a python script to create some appropriate environmental variables by running the script in whatever directory I'll be executing some simulation code, and I've read that I can't write a script to make these env vars persist in the mac os terminal. So two things: Is this true? and It seems like it would be a useful things to do; why isn't it possible in general? You can't do it from python, but some clever bash tricks can do something similar. The basic reasoning is this: environment variables exist in a per-process memory space. When a new process is created with fork()

Spring MVC 3.0: How do I bind to a persistent object

你。 提交于 2019-11-27 03:36:27
问题 I'm working with Spring MVC and I'd like it to bind a a persistent object from the database, but I cannot figure out how I can set my code to make a call to the DB before binding. For example, I'm trying to update a "BenefitType" object to the database, however, I want it to get the object fromthe database, not create a new one so I do not have to update all the fields. @RequestMapping("/save") public String save(@ModelAttribute("item") BenefitType benefitType, BindingResult result) { ..

How to store a dictionary on a Django Model?

最后都变了- 提交于 2019-11-27 03:16:31
I need to store some data in a Django model. These data are not equal to all instances of the model. At first I thought about subclassing the model, but I’m trying to keep the application flexible. If I use subclasses, I’ll need to create a whole class each time I need a new kind of object, and that’s no good. I’ll also end up with a lot of subclasses only to store a pair of extra fields. I really feel that a dictionary would be the best approach, but there’s nothing in the Django documentation about storing a dictionary in a Django model (or I can’t find it). Any clues? If it's really

How to use joda time with JPA (eclipselink)?

喜欢而已 提交于 2019-11-27 03:16:28
问题 I tried to use the DataTime in my entity class. Adding @Temporal(TemporalType.DATE) above the field, I got the error saying "The persistent field or property for a Temporal type must be of type java.util.Date, java.util.Calendar or java.util.GregorianCalendar" . I can introduce the conversion back and forth; using setters and getters as follows: @Temporal(TemporalType.DATE) private Calendar attendanceDate; public DateTime getAttendanceDate() { return new DateTime(this.attendanceDate); }

is localStorage on iPad Safari guaranteed to be persistent?

ぃ、小莉子 提交于 2019-11-27 02:48:17
问题 I've seen differences of opinion across the web on this. It has been said that starting with iOS 5.1, local data storage for HTML5 content on the iPad is no longer guaranteed to be persistent, however on Apple's current Safari developer pages (https://developer.apple.com/technologies/safari/html5.html), offline persistence is suggested to be guaranteed. Does anyone have any recent experience with this subject and able to comment on how reliable the database features of HTML5 are with Safari