persistence

How to prevent “Local transaction already has 1 non-XA Resource” exception?

风格不统一 提交于 2019-12-22 04:15:12
问题 I'm using 2 PU in stateless EJB and each of them is invoked on one method: @PersistenceContext(unitName="PU") private EntityManager em; @PersistenceContext(unitName="PU2") private EntityManager em2; @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW ) public void getCandidates(final Integer eventId) throws ControllerException { ElectionEvent electionEvent = em.find(ElectionEvent.class, eventId); ... Person person = getPerson(candidate.getLogin()); ... } @TransactionAttribute

JPA @OneToMany and composite PK

给你一囗甜甜゛ 提交于 2019-12-22 03:58:10
问题 I am working on a JPA project. I need to use a @OneToMany mapping on a class that has three primary keys. You can find the errors and the classes after this. javax.persistence.PersistenceException: No Persistence provider for EntityManager named JTA_pacePersistence: Provider named oracle.toplink.essentials.PersistenceProvider threw unexpected exception at create EntityManagerFactory: javax.persistence.PersistenceException javax.persistence.PersistenceException: Exception [TOPLINK-28018]

Class for pickle- and copy-persistent object?

最后都变了- 提交于 2019-12-21 17:49:17
问题 I'm trying to write a class for a read-only object which will not be really copied with the copy module, and when it will be pickled to be transferred between processes each process will maintain no more than one copy of it, no matter how many times it will be passed around as a "new" object. Is there already something like that? 回答1: I made an attempt to implement this. @Alex Martelli and anyone else, please give me comments/improvements. I think this will eventually end up on GitHub. """

How can i save the config of my app without using a database??? (using simple textfile)

给你一囗甜甜゛ 提交于 2019-12-21 17:25:22
问题 i need to save a simple field to configurate my APP, cause this, i wont use a database (it's only a field...), i need to save true or false value for this field on a file, and everytimes a section of my app wanna check if it is true they have to check this textfile, and not to open a connexion to a database i need to save the config for ever... i mean that when i exit from my app, and for example, i shut down my android device, when i start my device again and start my app, the config have to

what are some common problems with Hibernate/persistence?

人走茶凉 提交于 2019-12-21 13:03:46
问题 I have an application I'd like to test-proof against possible problems related to Hibernate and/or persistence. What other problems? How do I reproduce them (literally)? And how do you recover from them? To make it clear: I'm talking about multi-threaded cluster environment (the most complex one). My one: org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect) Reproduce: Load the object. UPDATE using HQL. Try to

org.hibernate.HibernateException: save is not valid without active transaction

一曲冷凌霜 提交于 2019-12-21 10:15:53
问题 I am creating JSF application and using some hibernate stuff in it. All I want to do is to save the entity into the database but I keep getting this exception: org.hibernate.HibernateException: save is not valid without active transaction At first I was getting this exception: org.hibernate.HibernateException: No CurrentSessionContext configured! Then I found that I need to add this into my hibernate configuration: <property name="hibernate.current_session_context_class">thread</property>

Delete then create records are causing a duplicate key violation with Spring Data JPA

淺唱寂寞╮ 提交于 2019-12-21 09:25:06
问题 So, I have this scenario where I need to take a header record, delete the details for it, then re-create the details in a different way. Updating the details would be way too much trouble. I basically have: @Transactional public void create(Integer id, List<Integer> customerIDs) { Header header = headerService.findOne(id); // header is found, has multiple details // Remove the details for(Detail detail : header.getDetails()) { header.getDetails().remove(detail); } // Iterate through list of

Persistence ignorance and DDD reality

主宰稳场 提交于 2019-12-21 05:43:06
问题 I'm trying to implement fully valid persistence ignorance with little effort. I have many questions though: The simplest option It's really straightforward - is it okay to have Entities annotated with Spring Data annotations just like in SOA (but make them really do the logic)? What are the consequences other than having to use persistance annotation in the Entities, which doesn't really follow PI principle? I mean is it really the case with Spring Data - it provides nice repositories which

Persisting entities using a REST API

早过忘川 提交于 2019-12-21 04:54:09
问题 For a project in Symfony2 I need to be able to persist / retrieve entities using an external RESTful API, instead of the database. Since Doctrine maps the entity to a row of a database table, I thought it should be easy to create a mapping from the entity to an external API as well. However, this is new for me and I can't seem to find any descriptions / tutorials about this. (perhaps I'm missing the right words for my Google-fu) I was hoping there is a solution similar to Doctrine. I'd rather

Update multiple rows using hibernate Criteria

杀马特。学长 韩版系。学妹 提交于 2019-12-21 04:34:19
问题 I am trying to run an update query which would look like this in sql: update studentMaster set sess_status = 'G' where ACADEM_YEAR = COURSE_YEAR; I am trying to re-create the query using Criteria like this: public void updateSessionStatus() { Session sess = factory.openSession(); Transaction tx = null; try { tx = sess.beginTransaction(); Criteria crit = sess.createCriteria(CollegeStudentsMaster.class); crit.add(Restrictions.eqProperty("academicYear", "courseYears")); CollegeStudentsMaster e =