eclipselink

eclipselink connection pooling

℡╲_俬逩灬. 提交于 2019-12-18 02:09:13
问题 If connection pooling is not defined in the persistence.xml for eclipse link, what is the default behavior? Will it open and close a JDBC connection for every transaction? Will it create a connection pool with some defaults? 回答1: The default connection pooling for EclipseLink when not using a data source is a pool of min/max 32 connections, with an initial of 1 connections. So each transaction will use a pooled connection, and not connect/disconnect. 回答2: If you use an application server

EclipseLink JPA `@PreUpdate` call not persisting

只愿长相守 提交于 2019-12-18 01:15:13
问题 I ran into some similar questions on StackOverflow, tried the solutions, but did not find an answer. I am using a fairly common JPA strategy to set last modified times on some entities. Set up the columns and the fields, then tag a method with @PreUpdate and let it set them equal to the current time. The problem is that I can see in the debugger that the method is being called and that the field is being updated, however in my DB logs I only see a SQL call to UPDATE the changed field that

EclipseLink and Sequence Generator Preallocation

大憨熊 提交于 2019-12-17 22:50:22
问题 I have an issue I can't get my head around. In hibernate I have no problem with the following: @GeneratedValue( strategy = GenerationType.AUTO, generator = "email-seq-gen" ) @SequenceGenerator( name="email-seq-gen", sequenceName="EMAIL_SEQ_GEN", allocationSize=500 ) Then in my schema.ddl I have this: CREATE SEQUENCE EMAIL_SEQ_GEN START 1 INCREMENT 500; Not much to see here. Everything works as expected. However, if I switch my provider to EclipseLink I get this error: The sequence named

How to catch and wrap exceptions thrown by JTA when a container-managed-tx EJB commits?

隐身守侯 提交于 2019-12-17 22:09:44
问题 I'm struggling with a problem with an EJB3 class that manages a non-trivial data model. I have constraint validation exceptions being thrown when my container-managed transactional methods commit. I want to prevent them from being wrapped in EJBException , instead throwing a sane application exception that callers can handle. To wrap it in a suitable application exception, I must be able to catch it. Most of the time a simple try/catch does the job because the validation exception is thrown

Entitymanager.flush() VS EntityManager.getTransaction().commit - What should I prefer?

风格不统一 提交于 2019-12-17 21:55:11
问题 What should I prefer when updating the database? What are the pros & cons with either method and when shall I use the one or the other? public void disemployEmployee(Integer employeeId, Date endDate) { Employee employee = (Employee)em.find("Employee", employeeId); employee.getPeriod().setEndDate(endDate); em.flush(); } public void disemployEmployee(Integer employeeId, Date endDate) { Employee employee = (Employee)em.find("Employee", employeeId); em.getTransaction().begin(); employee.getPeriod

Eclipselink Lazy Loading

大城市里の小女人 提交于 2019-12-17 21:33:02
问题 I am running a test on eclipselink JPA 2, to determine how lazy loading of a collection is working. I have assumed, the if you load an entity, then all eager elements are loaded first of all, then, within the JPA session, the lazy elements are loaded when you ask for them, or touch them (refer to them in some way, like getting the size of a lazy collection). The problem I have is this: when I detach the entity from the session, the lazy collection is loaded, and is available, even though I

EclipseLink “create-or-extend-tables” not working: “…unknown column…”

自闭症网瘾萝莉.ら 提交于 2019-12-17 21:23:52
问题 I am using EclipseLink 2.4.1 with Glassfish and a MySQL database for persisting entities. I added a field to an entity, and when I try to persist this entity it says the new field is 'unknown'. How are we supposed to use the new 'create-or-extend-tables' feature? I would have thought it would create a new column for this field. Some relevant information is below, let me know if you want more. Thanks in advance! Stack Trace ... Caused by: Exception [EclipseLink-4002] (Eclipse Persistence

Unmarshal a single element list fails

可紊 提交于 2019-12-17 21:07:13
问题 I'm running a sample (which i can't find anymore) from Blaise Doughans blog on Glassfish 3 using EclipseLink 2.5 MOXy for JAXB service. @XmlRootElement @XmlAccessorType(XmlAccessType.FIELD) public class Company { @XmlElementWrapper(name="employees") @XmlElement(name = "employee", type=Employee.class) private List<Employee> employees; } @XmlAccessorType(XmlAccessType.FIELD) public class Employee { private String id; private String name; } I added some annotations to the classes, to produce the

Setting orphanRemoval to true while migrating children from their parent to another parent

江枫思渺然 提交于 2019-12-17 20:37:17
问题 Important Notice : If you are reading this post, then consider looking into this post too for in-depth discussions. It is a quite usual practice/situation/requirement where children of a parent may be migrated to another parent. What happens, if orphanRemoval is set to true on the inverse side of such relationships? Consider as an example, any simple one-to-many relationship as follows. Inverse side (Department) : @OneToMany(mappedBy = "department", fetch = FetchType.LAZY, cascade =

JAXB unmarshalling multiple XML elements into single class

断了今生、忘了曾经 提交于 2019-12-17 19:01:48
问题 I have the following XML structure, which is modelling a single concept across multiple XML elements. This format is not in my control. <Output> <Wrapper> <Channel> <id>1</id> <type>x</type> </Channel> <Channel> <id>2</id> <type>y</type> </Channel> <ChannelName> <id>1</id> <name>Channel name</name> </ChannelName> <ChannelName> <id>2</id> <name>Another channel name</name> </ChannelName> </Wrapper> </Output> I want to model this in a database that I do have control over and can have a more