eclipselink

change the OptimisticLockPolicy to use local-time

帅比萌擦擦* 提交于 2019-12-11 14:09:19
问题 I'm using Eclipselink JPA, I have an Entity with a Timestamp field annotated with @Version por optimistic locking. By default, this sets the entitymanager to use database time, so, if I have to do a batch update it doesn't work properly as it query the database for time each time it wants to do an insert. How can I change the TimestampLockingPolicy to use LOCAL_TIME? The class org.eclipse.persistence.descriptors.TimestampLockingPolicy.class has a public method useLocalTime() but I dont know

EclipseLink entity mapping problem when using property accessor methods

前提是你 提交于 2019-12-11 13:52:38
问题 Given the class below does anyone know why EclipseLink implementation of JPA fails to map them to database entities? The following error is returned: Entity class [class com.my.entity.Y] has no primary key specified. It should define either an @Id, @EmbeddedId or an @IdClass. If you have defined PK using any of these annotations then make sure that you do not have mixed access-type (both fields and properties annotated) in your entity class hierarchy. @Entity @Access(AccessType.PROPERTY)

JPA and derby null pointer exception

╄→гoц情女王★ 提交于 2019-12-11 13:37:21
问题 I am trying to do a simple persistence with jpa 2.0 and derby but I keep getting a NullPointerException. Exception and entity class - http://pastebin.com/QqXhRdcN The code where I am trying to persist EntityManager em = emf.createEntityManager(); Course c = new Course("cse", 214, "fall", 2010); em.getTransaction().begin(); em.persist(c); em.getTransaction().commit(); em.close(); The null pointer exception occurs at line 171 which is the first line of the above code. Thanks in advance! 回答1:

Self ManyToMany with additional columns using JPA 2.0

送分小仙女□ 提交于 2019-12-11 13:29:50
问题 I have Application entity, want to express self bi-directional relationship with attribute in JPA. EX. QuoteStore(provider Application) provides services to online portal and many(consumer applications) and QuoteStore(consumer Application) consumes services from Siebel CRM and many (provider applications) The above approach works well when relationship is ManyToMany but not self (ex. App2DB or App2BizCase) For Self bidirectional ManyToMany relationship with attributes on application entity; I

EclipseLink and JPA columns of table not showing up

烂漫一生 提交于 2019-12-11 12:45:02
问题 In Eclipse, I try to create entity classes based on an existing database schema. The wizard works until the end and creates the appropriate classes. Except for one thing. Some classes are not being found by code as they're not generated. In the "Customize individual entities" dialog, all the tables show up. Some of them don't have any columns being displayed in this dialog. What works: I can create relationships, even to these "missing" columns I see these tables in Eclipses "Data Source

confused about Lazy loading

限于喜欢 提交于 2019-12-11 12:41:50
问题 While trying to do some tests on lazy loading, to check if i'm understanding it well, i got totally confused. Here's the entities i'm using on my test: @Entity public class Family { @Id private int id; @OneToMany(mappedBy="family", fetch=FetchType.LAZY) private Set<Person> members; //getters & setters public String toString(){ String s=""; for(Person p:getMembers()){ s+=p.getFirstName(); } return s; } } @Entity public class Person implements Comparable<Person>{ @Id private int id; private

eclipselink.query-results-cache.ignore-null not caching any result

雨燕双飞 提交于 2019-12-11 12:40:05
问题 I am using EclipseLink 2.5.0 I am trying to achieve following. Query an object using non-key filters. If result is not null, it should be cached, and future queries with same filter values should not go to data base. If no result is found, the result should not be cached and future queries with same filter values should go to data base. I think, I should be able to achieve it with eclipselink.query-results-cache.ignore-null hint, but if I include following <hint name="eclipselink.query

EclipseLink fails to fetch a scalar Boolean value

一曲冷凌霜 提交于 2019-12-11 12:19:54
问题 The following JPA criteria query succeeds on Hibernate (4.2.7 final). CriteriaBuilder criteriaBuilder=entityManager.getCriteriaBuilder(); CriteriaQuery<Boolean>criteriaQuery=criteriaBuilder.createQuery(Boolean.class); Root<UserTable> root = criteriaQuery.from(entityManager.getMetamodel().entity(UserTable.class)); criteriaQuery.multiselect(root.get(UserTable_.enabled)); ParameterExpression<String>parameterExpression=criteriaBuilder.parameter(String.class); criteriaQuery.where(criteriaBuilder

EclipseLink set column name for @JoinColumn(name = “”) at runtime

…衆ロ難τιáo~ 提交于 2019-12-11 12:16:54
问题 I need to change column names for all fields at runtime. I use eclipselink and do it via SessionCustomizer . However, I can change column names for usual columns, those which are not in any relations. Now I have a field in @ManyToOne relation and defines its column using @JoinColumn(name = "thisColumnToChage"). How to do it? This is my code: private void setNameMaping(ClassDescriptor desc){ desc.setTableName(NEW TABLE NAME); //setting columns for fields for (DatabaseMapping mapping : desc

Using EcliplseLink JPA how can I disable all the relationship lookups when persisting an object?

蓝咒 提交于 2019-12-11 12:05:23
问题 When I persist an object with a foreign key, I see in the logs that eclipselink goes off and does a verification query, like this: I also see that eclipselink finds this object and binds it. I don't want it to do either of these things. Basically I am trying to save object A, and A has a relationship with object B. When I go to insert a new A, all I have is the ID for B, not an instance of class B, and I am not interested in obtaining an instance of B in this case. Something like this: String