persistence

Hibernate could not initialize proxy - no Session

喜欢而已 提交于 2019-12-21 03:45:40
问题 My code retrieves all information related to the user: SessionFactory sessionFactory = HibernateUtilities.configureSessionFactory(); Session session = sessionFactory.openSession(); UserDetails ud = null; Set<Address> userAddress = null; try { session.beginTransaction(); ud = (UserDetails) session.get(UserDetails.class, 1); userAddress = ud.getAddresses(); session.getTransaction().commit(); } catch (HibernateException e) { e.printStackTrace(); session.getTransaction().rollback(); } finally {

Objectify doesn't store synchronously, even with now

我只是一个虾纸丫 提交于 2019-12-21 02:43:17
问题 My servlet should perform the following : when a user registers at a venue, I check whether he's currently registered somewhere (even if it is the same venue) if so, unregister him and to register him once again. I have the following code, which I've simplified in order to show my problem : Date tempDate = new Date(); Visit v = ofy().load().type(Visit.class) .filter(Visit.USER_ID, 5L) .filter(Visit.EXIT_DATE, null).first().get(); if(v != null) exitVenue(5L, 7L, tempDate); Visit visit = new

Best practice to join nhibernate and ASP.NET membership/role/profile services

不问归期 提交于 2019-12-20 12:25:01
问题 I've got a generic ASP.NET (MVC) application, that uses NHibernate as the model persistence layer, and ASP.NET Membership/role/profile services as the user management layer. The question is what can be considered as the best practice to create linkings between the domain data and the users. (For example is I want to create a forum system I want to link each topics/posts to a specific user, and want to display the user at each request). These are the posiibilites I've been thinking of: Store

Create C# classes based of MySQL table

不想你离开。 提交于 2019-12-20 10:23:50
问题 Is there anything built into .Net or visual studio that will allow my to create classes based off of a MySql table. I guess I am talking about persistence. I just want the class to be a 1 to 1 mapping of the table. Does anything free exist? 回答1: maybe you need something like this: select 'my_table' into @table; #table name select 'my_database' into @schema; #database name select concat('public class ',@table,'{') union select concat('public ',tps.dest,' ',column_name,'{get;set;}') from

Save entities to a REST API instead of DB using Doctrine 2

此生再无相见时 提交于 2019-12-20 09:48:47
问题 This is related to my other question: Persisting entities using a REST API. For a project in Symfony2 I need to be able to persist entities using an remote (third-party) RESTful API . I also want to be able to retrieve entities with data from that API. In other words, my objects are saved in the third-party database . They are not saved in my own database. Whenever I need to save data, or find data, I use their REST API. I have been pointed to several libraries, including one made by Doctrine

Is it possible to get gVim to remember window size?

ぃ、小莉子 提交于 2019-12-20 09:28:49
问题 I know how to set the initial window size in gVim, but how do I get it to automatically restore the window dimensions from last session? Is this even possible? 回答1: Edit: Corrected my answer. The mentioned winsize sessionoption only refers to the vim internal window layout, not the external dimensions. If you use :mksession and load the session on vim startup with gvim -S Session.vim you can include the window position and size into the session by including winpos and resize in the

Why put a DAO layer over a persistence layer (like JDO or Hibernate)

浪子不回头ぞ 提交于 2019-12-20 09:05:11
问题 Data Access Objects (DAOs) are a common design pattern, and recommended by Sun. But the earliest examples of Java DAOs interacted directly with relational databases -- they were, in essence, doing object-relational mapping (ORM). Nowadays, I see DAOs on top of mature ORM frameworks like JDO and Hibernate, and I wonder if that is really a good idea. I am developing a web service using JDO as the persistence layer, and am considering whether or not to introduce DAOs. I foresee a problem when

EJB @PersistenceContext EntityManager Throws NullPointerException

荒凉一梦 提交于 2019-12-20 06:39:54
问题 I'm having a problem with injecting EntityManager by using @PersistenceContext. I try to inject EntityManager in EJB class with @PersistenceContext and I always get NullPointerException. Here is EJB class: @Stateless public class BookEJB { public BookEJB(){ } @PersistenceContext(unitName = "BookWebStorePU") private EntityManager em; public Book createBook(Book book) throws Exception { System.out.println("EM: " + em); em.persist(book); return book; } public Book findBookByIsbn10(String isbn10)

How to use NSUserDefaults to store an array of dictionaries

会有一股神秘感。 提交于 2019-12-20 06:03:52
问题 Trying to store an array of dictionaries with NSUserDefaults . var theTasks: [[String:Any]] = [["num":1,"title":"example","colour":"red"]] let defaults = NSUserDefaults.standardUserDefaults() defaults.setObject(theTasks, forKey: "myTasks") defaults.synchronize() let selected = theTasks[1] Gives error: Cannot convert value of type '[[String:Any]]' to expected argument of type 'AnyObject?' 回答1: Swift 3.x In Swift 3 it has changed so now it needs to be saved as [Any] Any Array and use

JPA and many-to-many relations in google app engine

与世无争的帅哥 提交于 2019-12-20 03:03:33
问题 I have entities A and B, and A can have set of B. The same instance of B can belong to several A. So there is classical many-to-many relation here. In GAE there is no direct support of many-to-many relations, instead they're offering an ability to use sets of keys for related relations. So in A I will maintain set of keys of records in B. Now the problem is - how can I query for objects of type B belonging to given object of type A and matching certain criteria? In plain SQL I would do that