eclipselink

How to change EclipseLink in GlashFish 4.0?

久未见 提交于 2019-12-07 01:52:19
问题 I want to change EclipseLink from 2.5.0 to 2.5.1 in GlashFish 4.0. I have downloaded the OSGi bundle and replaced the following jar files org.eclipse.persistence.antlr.jar org.eclipse.persistence.jpa.jar org.eclipse.persistence.asm.jar org.eclipse.persistence.jpa.modelgen.jar org.eclipse.persistence.core.jar org.eclipse.persistence.oracle.jar javax.persistence.jar under $GLASSFISH_HOME/glassfish/modules . After doing this, the version still remains the same. The following code, String version

Is there a elegant and common way for converting PostgreSQL hstore to JPA 2.1 DataType?

吃可爱长大的小学妹 提交于 2019-12-06 22:13:40
问题 I have used JPA 2.1 Converter to convert PostgreSQL hstore to Map<String, String> . But I didn't find a universal way for different JPA providers such as EclipseLink and Hibernate. So I need to write different Converters for each JPA provider. The following is the example which uses different Converters for EclipseLink and Hibernate. https://github.com/phstudy/jpa-converter-sample Is there an universal way for different JPA providers? 回答1: The PostgreSQL JDBC driver provides a org.postgresql

Spring + JPA: object does not get fetched from the database

和自甴很熟 提交于 2019-12-06 21:42:50
I am implementing an online shop. I have the following code for saving an order: @Service @Transactional public class OrderServiceImpl extends GenericServiceImpl<Order, Integer> implements OrderService { @Inject private ItemRepository itemRepository; @Override public void saveOrder(Order order) { this.updateItemsAccordingToOrderedQuantities(order); repository.save(order); } private void updateItemsAccordingToOrderedQuantities(Order order) { List<OrderedItem> orderedItems = order.getOrderedItems(); for (OrderedItem orderedItem : orderedItems) { // fetch from database Item item = itemRepository

Is @ManyToMany(mappedBy = … ) + @OrderColumn supported by the JPA?

随声附和 提交于 2019-12-06 19:37:38
问题 I have an entity mapped as following: @Entity @Table(name = "Groups") @IdClass(value = GroupId.class) public class Group implements Serializable { @Id @Column(name = "round_id") private Integer roundId; @Id @Column(name = "ordinal_nbr") private Integer ordinalNbr = 0; ... } It has a composite key (round_id, ordinal_nbr) to indicate the order of groups in a round. Now imagine a join table containing entities that link the ordered groups via a self reference (from Group to Group): CREATE TABLE

When I use A JPA Query's getResultList(), are the results detached or managed?

落花浮王杯 提交于 2019-12-06 19:35:00
问题 When I have a JPA Query that I call .getResultList(), It gives me back a List of objects. Are the objects in that list managed or detached? That is, do I have to worry about merging or persisting them later if I make changes to them, or will those changes be picked up automatically? 回答1: Yes, the objects returned from .getResultList() are managed. When you made changes on the managed objects, you do not worry about merging as those changes will be picked up by the EntityManager automatically.

Check whether a JTA transaction is successfully committed

倾然丶 夕夏残阳落幕 提交于 2019-12-06 15:56:58
Is there a way to check if the current transaction is committed or not in JPA entity listeners something like the following? @ApplicationScoped public class EntityListener { @Inject private Event<EntityEvent> event; @Inject private EntityManager entityManager; @Resource private UserTransaction userTransaction; @PostPersist @PostUpdate @PostRemove public void onChange(Entity entity) { // This is only a piece of pseudo code. if (userTransaction.isComitted()) { // Do something. } } } Entity listeners in JPA 2.1 are treated as CDI beans that depend upon CDI injection(s) and a transaction context

JPA ManyToMany where annotation

拈花ヽ惹草 提交于 2019-12-06 15:38:07
I'm using JPA / EclipseLink 2.5.2 and want to add an additional where clause to my ManyToMany Mapping. The SQL Code would look like this: SELECT * FROM Friends f INNER JOIN User u ON f.friend_id = u.id WHERE f.verified=1; So I managed to do the JoinMapping with: @Entity @NamedQueries({ @NamedQuery(name="User.findAll", query="SELECT u FROM User u"), @NamedQuery(name="User.login", query="SELECT a FROM User a WHERE a.username = :name and a.password = :password"), @NamedQuery(name="User.findId", query="SELECT a FROM User a WHERE a.id = :id"), @NamedQuery(name="User.findName", query="SELECT a FROM

JPA and database Flex fields

穿精又带淫゛_ 提交于 2019-12-06 15:04:47
'Flex fields' is a term for altering a table at the customer site to add extra columns to a table to hold custom pieces of information about that table's entity. I was wondering if anyone has dealt with supporting this mechanism with jpa, specifically eclipselink. We wish to do this because we allow filtering of the base rows based on values in these customer specified fields, and having these fields in an association table causes multiple alias joins to this auxilliary table. An obvious approach (at least it would seem to me) would be to define an aspect(s) that injects the new fields into

JPA 2.0 EclipseLink Check for unique

喜你入骨 提交于 2019-12-06 15:01:13
问题 I have a collumn as unique=true.. in Exam class.... I found that because transactions are commited automaticaly so to force the commit i use em.commit() However i would like to know how to check if it is unique.Running a query isnt a solution because it may be an instert after checking because of the concurency.... Which is the best way to check for uniqness? List<Exam_Normal> exam_normals = exam.getExam_Normal(); exam.setExam_Normal(null); try { em.persist(exam); em.flush(); Long i = 0L; if

JPQL Not a Selected Expression error

末鹿安然 提交于 2019-12-06 14:57:14
I have the following JPQL in ProductList Entity class which executes as expected. select DISTINCT new foo.bar.ProductListDTO(p.prodId, " + CASE WHEN (p.prodId = 'ZCX') THEN CONCAT(p.prodDesc, ' - ', e.userId) ELSE p.prodDesc END) from ProductList p LEFT JOIN p.productCatalogueList c where c.userId='ZAM' ProductListDTO class public ProductListDTO(String prodId, String prodDesc, String userId) { this.prodId = prodId; this.prodName = prodDesc; this.userId = userId; } What I would like to achieve is add ORDER BY to the query. When p.prodDesc is added to ORDER BY clause, I am getting error not a