persistence

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

喜夏-厌秋 提交于 2019-11-28 00:07:31
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.createEntityManagerFactory("myPetStorePU"); EntityManager em = emf.createEntityManager(); then emf gets successfully

JPA - difference in the use of the mappedBy property to define the owning entity

空扰寡人 提交于 2019-11-27 23:08:13
What exactly is the difference in the following two declarations B is the owning side @Entity class A { @Id int id; @OneToOne B b; } @Entity class B { @Id int id; @OneToOne(mappedBy="b") A a; } A is the owning side @Entity class A { @Id int id; @OneToOne(mappedBy="a") B b; } @Entity class B { @Id int id; @OneToOne A a; } Thinking of this in "normal SQL" i think it is the same as having two tables each having the other table's foreign key. What i don't understand though is what is the effect of specifying which entity is the owning side i.e using the 'mappedBy' property. What does this actually

javax.persistence.PersistenceException: org.hibernate.PersistentObjectException: detached entity passed to persist

限于喜欢 提交于 2019-11-27 23:05:43
问题 Using JPA with Hibernate, I got an exception when running the following code. The first time I run it, everything goes fine and the data is inserted in the database. The second time, when the data should be updated, it fails: @AdminTx public void processSite(Site site) { FluxBoutiqueMapping mapping = mapper.generateMappingFromUrl(site); Boutique boutique; for (FluxBoutiqueMapping.Boutique fluxBoutique : mapping.getListe().getBoutiques()) { log.error("Dans la boucle"); boutique = daoAdmin

Using PLists for Persistence on iPhone

試著忘記壹切 提交于 2019-11-27 22:49:16
问题 Simple question about property lists within an iphone app. I know you can read data in from a plist, but is there a way to write user-inputted data to a plist? If so, how? It's easy to find tutorials on reading information from plists, but I'm having trouble finding resources on writing to plists. 回答1: This is how I write data items to a plist: [myPlistFile setInteger: myInt forKey: @"someKey"]; Of course, you can change setInteger with setBool, etc for different types. Hope this helps! --

iOS persistent storage strategy

∥☆過路亽.° 提交于 2019-11-27 20:10:24
I'm developing an app which will save data to the local file system. The data that will be saved will be mostly NSString and NSDate. The data will not be saved that often, perhaps new data will be entered 10 times at a typical usage. The data should also of course be retrievable (CRUD) How should I save this data? First of all is it necessary to model these objects? If not should I use property lists? Or SQLLite3? Else should I archive the class models? Use SQLLite3? EDIT: I accidentally left out some vital information about the app. Actually my app will be having 2 data models which have an

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

ぃ、小莉子 提交于 2019-11-27 20:09:30
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 '$password'."; } else echo "Please <a href=authenticate2.php>click here</a> to log in."; ?> Based on the

JAXB Configuration was broken by upgrading from JDK 1.7 to JDK 1.8 u05 for collections

浪尽此生 提交于 2019-11-27 19:27:30
问题 The code below used to work under the JAXB implementation used by JDK 1.7, but now under JDK 1.8 it's broken. In the code below you will find the key change that seems to make it work in 1.8. The "fix" under 1.8 is not really a fix because it's bad practice to expose internal collections for direct modification by the outside world. I want to control access to the internal list through my class and I don't want to complicate things by making observable collections and listening to them. This

Persisting data suited for enums

╄→尐↘猪︶ㄣ 提交于 2019-11-27 18:34:33
Most projects have some sort of data that are essentially static between releases and well-suited for use as an enum, like statuses, transaction types, error codes, etc. For example's sake, I'll just use a common status enum: public enum Status { ACTIVE(10, "Active"); EXPIRED(11, "Expired"); /* other statuses... */ /* constructors, getters, etc. */ } I'd like to know what others do in terms of persistence regarding data like these. I see a few options, each of which have some obvious advantages and disadvantages: Persist the possible statuses in a status table and keep all of the possible

Remember (persist) the filter, sort order and current page of jqGrid

血红的双手。 提交于 2019-11-27 17:52:11
My application users asked if it were possible for pages that contain a jqGrid to remember the filter, sort order and current page of the grid (because when they click a grid item to carry out a task and then go back to it they'd like it to be "as they left it") Cookies seem to be the way forward, but how to get the page to load these and set them in the grid before it makes its first data request is a little beyond me at this stage. Does anyone have any experience with this kind of thing with jqGrid? Thanks! PROBLEM SOLVED I eventually ended up using cookies in javascript to store the sort

Java: Getting Bytecode of Class at Runtime from within the Same JVM

两盒软妹~` 提交于 2019-11-27 17:50:57
问题 Related to: Is there a way to obtain the bytecode for a class at runtime? I'm adding durability to Clojure, and I'm finally at the point where I'm ready to add functions. In Clojure, functions are byte compiled into classes with invoke methods (among others). In this way, functions are first class. To make these durable, I need to serialize and deserialize these classes. How do I get the bytecode for the class without having access to the .class file? Please correct me if I'm mistaken, but