jpa-2.0

Properties reference for hibernate in persistence.xml

淺唱寂寞╮ 提交于 2019-12-02 22:36:29
Does anyone know a link, post, book or something else where are explained and nominalized all properties that you need and can use in persistence.xml file? Piotr Nowicki The JPA 2.0 supported properties ( javax.persistence.* ) can be found in JPA 2.0 specification . Vendor-specific properties can be found in appropriate vendor documentation: Hibernate properties ( hibernate.* ) EclipseLink properties ( eclipselink.* ) Ilya Full list of properties, that hibernate uses, you can find in class org\hibernate\cfg\Environment.java in Hibernate distribution. Javadoc here I think there are actually 2

EJB 3.1 Transaction, EntityManager

点点圈 提交于 2019-12-02 21:08:53
问题 I have an application which processes IQ stanzas via smack (eventbased java library). We now switch from vanilla Tomcat to glassfish 3.1 and i would like to switch to ejb 3.1. @Stateless public class DispatchIQService { private static Logger log = Logger.getLogger(DispatchIQService.class); @PersistenceContext(unitName="hq") private EntityManager em; .... public void process(XMPPConnection connection, IQ rawRequest) { log.debug("Raw Provider IQ: " + rawRequest.toXML()); RawResponse answer =

How to implement polymorphic JPA entities with generic relations

浪子不回头ぞ 提交于 2019-12-02 20:46:56
I'm trying to use JPA 2.0 to create polymorphic entities with generic relations. There should be two tables, an event table and a notification table. Inside those table are concrete entities that are related to one another, like so: Event <---------- Notification<X extends Event> | | LoginEvent <------ LoginNotification extends Notification<LoginEvent> Logically this should be possible in hibernate, as it is possible in SQL: +----------+ +----------+ | Event | | Notif | +----------+ +----------+ | | | Id | | Id | <- | Evt_id | | Type | <- | Type | | ... | | ... | +----------+ +----------+ This

How does the UserTransaction and the EntityManager interact?

喜你入骨 提交于 2019-12-02 20:43:01
This is an academic question; I have no broken code in relation to this. I just want to expand my understanding of what is happening under the hood. The code pattern I have been using (copied from books and tutorials) in my JPA DAO for my typical JSF web applications is basically this: public class someDAO { @PersistenceContext protected EntityManager em; @Resource private UserTransaction utx; public void persist(Entity entity) { try { utx.begin(); em.persist(entity); utx.commit(); } catch ( // gawd awful long list of possible exceptions ) // etc So my questions are as follows: Why are the

DB2 + JPA throwing an error: column not found in the table

房东的猫 提交于 2019-12-02 20:19:30
问题 The DB2-express is throwing an error that seems impossible, when JPA tries to persist an entity: ReportingSQLException: "ITEMID" is not valid in the context where it is used.. INSERT INTO NULLID."DynamicDatabaseTable" ("colname", "rownumber", "value") VALUES (?, ?, ?) [params=?, ?, ?] Since ITEMID is not used in the query above, how can this error be? The ITEMID is an auto-identity-generated column. I have tried executing manually the query and it works OK, so anybody know what's all about?

“Not in” constraint using JPA criteria

不想你离开。 提交于 2019-12-02 20:07:24
I am trying to write a NOT IN constraint using JPA Criteria . I've tried something like this: builder.not(builder.in(root.get(property1))); though I know it will not work. In the above syntax, how can I add the collection / list against which property1 that will be checked? jYeory builder.not(root.get({field_name}).in(seqs)) seqs is collection. 来源: https://stackoverflow.com/questions/5115422/not-in-constraint-using-jpa-criteria

Reference key issue while doing many to many relationship using @ElementCollection, @MapKeyJoinColumn

时光怂恿深爱的人放手 提交于 2019-12-02 19:54:37
问题 i am trying on many to many relationship, Team member can work on multiple projects and a project can have multiple team member , the table structure is as follows, create table TBL_PROJECT_ONE( id integer primary key generated always as identity(start with 12,increment by 3), name varchar(50) ) create table TBL_TEAM_MEMBER_ONE( id integer primary key generated always as identity(start with 7,increment by 5), name varchar(50), salary integer ) create table EMP_PRJ_CADRE( MEMBER_ID integer

JPA Nested Transactions And Locking

你说的曾经没有我的故事 提交于 2019-12-02 19:20:43
Consider the scenario two methods exists in different stateless bean public class Bean_A { Bean_B beanB; // Injected or whatever public void methodA() { Entity e1 = // get from db e1.setName("Blah"); entityManager.persist(e1); int age = beanB.methodB(); } } public class Bean_B { //Note transaction @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) public void methodB() { // complex calc to calculate age } } The transaction started by BeanA.methodA would be suspended and new transaction would be started in BeanB.methodB. What if the methodB needs to access same entity that was

Add WHERE IN clause to JPA Specification

你。 提交于 2019-12-02 18:19:33
问题 I'm trying to implement search functionality limited by IN clause: I want to implement search implementation with filter limitation: @GetMapping("find") public Page<MerchantUserDTO> getAllBySpecification( @And({ @Spec(path = "name", spec = LikeIgnoreCase.class), @Spec(path = "login", spec = LikeIgnoreCase.class), @Spec(path = "email", spec = LikeIgnoreCase.class), }) Specification<Users> specification, @SortDefault(sort = "login", direction = Sort.Direction.DESC) Pageable pageable ) { return

MSSQL - JPA - Character encoding for Special characters - appending 'N' nativeQuery

柔情痞子 提交于 2019-12-02 18:19:02
问题 I'm using Spring 4.3.1 with JPA 2.0 and connected to MSSQL. I'm using JpaRepository's save method to insert and update data. One of the fields has nvarchar which can contain special characters like Latin, Chinese. Also, I have set below JPA properties in applicationContext-hibernate.xml. <prop key="hibernate.connection.CharSet">UTF-8</prop> <prop key="hibernate.connection.useUnicode">true</prop> <prop key="hibernate.connection.characterEncoding">UTF-8</prop> When I save the data, all the