eclipselink

java.time YearMonth as a type within entity

假如想象 提交于 2019-12-06 07:17:19
How do you use YearMonth within an entity? I have seen a lot of stack overflow answers about a converter? Is this still needed and if so how? @Basic(optional = false) @NotNull @Column(name = "cc_exp_date") private YearMonth ccExpDate; The exception I am getting is below. Could I just convert this into a date within the set method and convert back to YearMonth within the get method of the entity as a work around? MysqlDataTruncation: Data truncation: Incorrect date value: '\xAC\xED\x00\x05sr\x00\x0Djava.time.Ser\x95]\x84\xBA\x1B"H\xB2\x0C\x00\x00xpw\x06\x0C\x00\x00\x07\xE2\x02x' for column 'cc

Disable JPA EclipseLink 2.4 cache

落花浮王杯 提交于 2019-12-06 06:20:01
问题 I'm trying to disable EclipseLink 2.4 cache so if the data gets changed in DB by other applications, same data gets refreshed in my application, which is using EclipseLink 2.4, without restarting it. None of these properties seems to work: <shared-cache-mode>NONE</shared-cache-mode> ... <property name="eclipselink.cache.shared.default" value="false"/> <property name="eclipselink.cache.size.default" value="0"/> <property name="eclipselink.cache.type.default" value="NONE"/> <property name=

How to cascade persist only new entities

爱⌒轻易说出口 提交于 2019-12-06 06:14:05
问题 I'm having trouble figuring out how to set up JPA persistence (using EclipseLink and transaction-type="RESOURCE_LOCAL") correctly for the following entities: @Entity public class User { // snip various members @ManyToMany private List<Company> companies; public void setCompanies(List<Company> companies) { this.companies = companies; } } @Entity public class Company { // snip various members } What I'm trying to do is set up a cascade for the companies list so that, if a new Company that hasn

EclipseLink Audit / History / Track changes

跟風遠走 提交于 2019-12-06 05:48:12
问题 i've tried to implement a way to track data changes and create a history log for my application. Because i'm using EclipseLink it should be easy and possible to get the changes like they write on the EclipseLink FAQ The first solution works but the second event based won't work. Everytime the event is raised the ObjectChangeSet is null. The reason why i'm not simply using HistoryPolicy is that i wan't to store information about the logged on user (not the db user) and the changed data to a

How to use EntityManager from @PrePersist?

不羁的心 提交于 2019-12-06 05:47:34
I have "post" entity/table with this "schema": @Id @GeneratedValue(strategy = GenerationType.AUTO) int id; @GeneratedValue(strategy = GenerationType.AUTO) private Integer postId; private Integer revisionId; private Boolean isCurrentRevision; So, table contains posts, each of them has multiple revisions, but only of them (for each post) is current. Now, let's say I want to persist another revision of existing post (i.e. update post): I need to find highest existing revisionId for this postId, increment it and set it to revisionId. Also this is the new current revision and so it should be marked

Indexed element access in JPQL

[亡魂溺海] 提交于 2019-12-06 05:19:11
Is it possible to do indexed element access in JPQL like in HQL : select o from Order o where o.items[0].id = 1234 I couldn't find something related in the JPA 2 specs, I am targeting EclipseLink JPA here, so if you come up with an EclipseLink solution, that's ok as well, although a JPQL standard solution is preferred. The INDEX function should do the trick (actually I tested it and it does): SELECT o FROM Order o JOIN o.items i WHERE i.id = 1234 AND INDEX(i) = 0 From the JPA 2.0 specification ( 4.6.17.2.2 Arithmetic Functions ): The INDEX function returns an integer value corresponding to the

Multi tenancy with spring data jpa and eclipselink

北城余情 提交于 2019-12-06 05:00:35
问题 I'm trying to add multi tenancy support to my Spring data jpa repositories. I would like to set dynamically the tenant id per request, but it does not work for the custom finder findBy* methods on repository. I've followed this guide: http://codecrafters.blogspot.sk/2013/03/multi-tenant-cloud-applications-with.html My repository looks like this: public interface CountryRepository extends PagingAndSortingRepository<Country, Long> { Country findByName(String name); Country findByIsoCountryCode

Constructor queries on a non-persistent entity unexpectedly fail to supply a Boolean parameter as a constructor argument

 ̄綄美尐妖づ 提交于 2019-12-06 04:48:14
There are two tables in MySQL database user_table feedback The relationship between them is intuitive - one to many from user_table to feedback . I need to fetch only a list of selected columns from these tables which are From feedback feedbackId (java.lang.Long) feedbackTitle (java.lang.String) feedbackDescription (String, decorated by @Lob ) feedbackDate (org.joda.time.DateTime) testimonial (java.lang.Boolean) From user_table userId (java.lang.Long) firstName (java.lang.String) These many fields out of many others are required to get by executing a query. The criteria query is as follows.

ClassCastException in JPA Entitiy after redeploy (Glassfish 3.1.2)

拜拜、爱过 提交于 2019-12-06 03:52:31
问题 I have a strange effect when undeploying and deploying a WebArchive (.war) with Glassfish 3.1.2. $ asadmin undeploy myWebApp; asadmin deploy target/myWebApp.war It deploys normally, but when I fetch an entity bean via the entity manager, it throws an Exception: [#|2012-12-11T15:26:09.772+0100|SEVERE|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=119;_ThreadName=Thread-2;|java.lang.ClassCastException: org.YourEntity cannot be cast to org.YourEntity The

EJB Glassfish v3.1.2 client passed data to session bean is always null

对着背影说爱祢 提交于 2019-12-06 02:48:54
I am having a problem when calling session bean method passing method parameters from client application, the data reaches the method call is always null or set to default value. while the process of the method works well with the object for example: -we have method to persist an object entity addStudent(Student student); - from the client we create the student object setting student fields like student name and so on, calling the method addStudent(ourStudent); this ourStudent reaches method with fields of null or default value. the student is added with these empty fields. Thanks in advance.