eclipselink

How can I prevent JPA from setting an embeddable object to null just because all its fields are null?

三世轮回 提交于 2019-12-06 02:46:36
问题 Although counterintuitive and apparently not required by the JPA standard, both Eclipselink and Hibernate go to great lengths to create the following source of NullPointerExceptions: When all fields of an object embedded in an entity are null, then they replace the field itself by null. Here is a simplified example: @Embeddable public class Period { private Date start; public Date getStart() { return start; } private Date end; public Date getEnd() { return end; } public boolean equals(Period

Can't insert PGpoint type with JPA

白昼怎懂夜的黑 提交于 2019-12-06 01:32:59
I am trying to persist one of my JPA/EclipseLink models, one attribute location of type org.postgresql.geometric.PGpoint is not inserting correctly. My model looks something like this: @Entity @NamedQuery(name="Entity.findAll", query="SELECT * FROM Entity e") public class Entity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; @Column(name="name") private String name; @Column(name="location") private PGpoint location; @Column(name="date") private Timestamp date; @Column(name="user_id") private Integer user_id; /* getters and setters */ I am getting this exception:

How to set namespace aware to false?

坚强是说给别人听的谎言 提交于 2019-12-06 00:32:33
问题 I'm trying to parse some XML with EclipseLink MOXy, and it's failing on the line with the xsi attribute. If I remove this, it parses fine. However, I've got 100GiB of XML to wade through and changing the source files is not an option. It's been suggested that if I can set XmlParser.setNamespaceAware(false) then it should work - but I've got no idea how to configure this, without breaking right into the guts of MOXy. <record> <header> <!-- citation-id: 14404534; type: journal_article; -->

How do you query the EclipseLink version at runtime (plus JPA meta data)?

≡放荡痞女 提交于 2019-12-05 22:58:00
Question pretty much says it all. Is there an equivalent for org.hibernate.Version.getVersionString() in EclipseLink? Why isn't there a portable (JPA) way to query provider information in general? Never used it but from the Eclipselink javadoc you could try the following class: org.eclipse.persistence.Version There is a static class and static method to get this information. Example: How to print in java code AbstractSessionLog.getLog().log(SessionLog.INFO, DatabaseLogin.getVersion()); 来源: https://stackoverflow.com/questions/9617691/how-do-you-query-the-eclipselink-version-at-runtime-plus-jpa

JPA database delimiters

放肆的年华 提交于 2019-12-05 22:07:50
I have a two entity classes called User and Group, both reserved words that need to be delimited in order for the database to accept them as tables. Annotating the entities with: @Table(name = "\"USER\"") does the trick, but I read that EclipseLink allows you to specify a global that automatically delimits names. According to http://dev.eclipse.org/mhonarc/lists/eclipselink-users/msg03434.html , you need to include the following in orm.xml: <persistence-unit-metadata> <persistence-unit-defaults> <delimited-identifiers/> </persistence-unit-defaults> </persistence-unit-metadata> I have annotated

JPA Eclipselink getting wrong sequence number

风格不统一 提交于 2019-12-05 21:52:00
I'm using some Entities mapped to Oracle DB-Tables. For ID-Generation I'm using a sequence generator annotated as following: @Id @SequenceGenerator(name = "SEQ_RULES", sequenceName = "SEQUENZ_RULES") @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_RULES") @Column(name = "SERIALNO") protected Long serialno; During programm execution I make a new Instance from my Entity and want to persist this generated one. After restart of the database I'm getting wrong sequence numbers through JPA-EclipseLink, but not through the Console directly on the database. I turned on following

Eclipse Warnings: class javax.persistence.* not found

a 夏天 提交于 2019-12-05 21:28:45
This is my first time really playing around with Java development using Eclipse. I am trying to use EclipseLink's implementation of the JPA. I moved all of my entities into a separate package "entities". I have the persistence.xml in a separate JPA project called "dataModeling". Everything builds and runs fine. Just about every project depends on my entities. However, I'm seeing a warning Class javax.persistence.Entity not found - continuing with a stub. , etc. showing up because the dependent projects don't reference EclipseLink. The solution is to go into each dependent project's properties

Java-EE6: FetchType.LAZY with static weaving throws strange exception

若如初见. 提交于 2019-12-05 20:00:44
My Solution consists of 3 different projects: EJB project with Netbeans auto-generated Facades to manage Entity classes and the persistence.xml Class-Library that holds all @Entity annotated and statically weaved database classes and the remote interfaces for the facade ejb's (shared between EJB and stand-alone client) Stand-alone Client that consists mainly of Swing GUI classes I use Glassfish 3.1.2, Eclipselink 2.3 as JPA-provider, Netbeans 7.1.1 and a MySQL database. I configured an Ant-task that statically weaves my entity classes on the basis of the persistence.xml. I have several

EclipseLink: Query to MappedSuperclass fails

半腔热情 提交于 2019-12-05 19:44:21
My application is a store selling fishes, aquariums etc. I want to get a list of top 10 items among all the items based on sales count. I use the following class: @MappedSuperclass @NamedQueries({ @NamedQuery(name="getTopItems",query="SELECT x FROM FishStoreItem x ORDER BY x.salescnt DESC, x.title DESC") }) public abstract class FishStoreItem extends DomainSuperClass implements Serializable { ...... } Problem is in the following exception: Exception [EclipseLink-8034] (Eclipse Persistence Services - 2.0.0.v20091127-r5931): org.eclipse.persistence.exceptions.JPQLException Exception Description:

ResultSet.next very slow only when query contains FIRST_ROWS or ROWNUM restriction

自古美人都是妖i 提交于 2019-12-05 17:40:38
I execute a native query using entityManager.createNativeQuery(sqlQuery); query.setMaxResults(maxResults); List<Object[]> resultList = query.getResultList(); To speed up the query, I thought to include the FIRST_ROWS(n) hint or limiting using WHERE ROWNUM > n . Using instrumentation, I see that indeed OraclePreparedStatement.executeQuery is faster, but a lot more time is spent in EJBQueryImpl.getResultList leading to an overall very poor performance. Looking more into detail, I see that every 10th call of ResultSet.next() takes about as long as executeQuery itself(). This strange behaviour