jpa-2.0

Hibernate mysql čć

穿精又带淫゛_ 提交于 2020-01-03 05:14:29
问题 Im having problem when i try to save Patient with familyname = 'Lučić' in MYSQL database using hibernate + jpa. When i do regular INSERT INTO, letter č and ć are displayed correctly in database and on my jsf form, so im sure that charset on my form is correct and in database. Here is my hibernate configuration: app_persistance.dialect=org.hibernate.dialect.MySQLDialect app_persistance.show_sql=true app_persistance.generateDdl=true app_persistance.minPoolSize=1 app_persistance.maxPoolSize=10

Custom like predicate to handle custom user defined types (Hibernate UserType)

半腔热情 提交于 2020-01-03 04:00:27
问题 I recently stumbled upon a problem where I have to build a JPA criteria with like predicate that accepts a custom type that is an implementation of UserType. The custom type I'm dealing with is nothing more than String wrapped with some additional info. I've done it for Hibernate criteria with implementing the Criterion interface from Hibernate and it works fine. I have to do the same now for JPA, but the Hibernates implementation of Predicate, the LikePredicate which is created when calling:

JSF 2 OpenJPA 2 Glassfish 3.1 WEB9031 Error

痴心易碎 提交于 2020-01-03 01:46:14
问题 I got this error which according to Apache Support is an issue relating with Glassfish rather than OpenJPA: java.lang.IllegalStateException: WEB9031: WebappClassLoader unable to load resource [org.apache.openjpa.util.LongId], because it has not yet been started, or was already stopped The stacktrace is: Caused by: java.lang.IllegalStateException: WEB9031: WebappClassLoader unable to load resource [org.apache.openjpa.util.LongId], because it has not yet been started, or was already stopped at

jpa 2.0 criteria api expression for sql minus

我只是一个虾纸丫 提交于 2020-01-02 13:45:12
问题 How do you create a jpa Criteria expression that is equivalent to the sql minus statement example SELECT mod_code FROM SRS.Table1 MINUS SELECT mod_code FROM SRS.Table2; 回答1: Minus does not exist but you can do something like that: select t1.mod_code from Table1 t1 where not exists (select t2 from table2 t2 where t2.mode_code = t1.mode_code) 来源: https://stackoverflow.com/questions/6923801/jpa-2-0-criteria-api-expression-for-sql-minus

Using @IdClass for storing entity with composite primary key, but fails to persist

為{幸葍}努か 提交于 2020-01-02 02:40:28
问题 my id class as follows, public class EmployeeId implements Serializable{ public EmployeeId(){} public EmployeeId(Integer id, String country){ this.id = id; this.country = country; } private Integer id; private String country; @Override public int hashCode(){ return this.getCountry().hashCode() + getId(); } @Override public boolean equals(Object o){ boolean flag = false; EmployeeId myId = (EmployeeId) o; if((o instanceof EmployeeId) && (this.getCountry().equals(myId.getCountry())) && (this.id

JSF 2: h:link and getrowdata

a 夏天 提交于 2020-01-01 17:05:46
问题 If I have a h:dataTable in books.xhtml providing a list of records and I want to view a particular record, then add or edit that record, currently I have this: <h:dataTable #{BookBean.books}" var="books"> <h:link outcome="bookview" value="#{books[1]}"> <f:param name="id" value="#{books[2]}" /> </h:link> </h:dataTable> I found out that I need to include <f:param> in order to show the CSS status of clicked link; otherwise if I don't have <f:param> , every time I clicked on a link rendered by h

Eager fetch does not seem to join

孤街醉人 提交于 2020-01-01 14:33:08
问题 I'm using play 2.0.4 with Java. I'm trying to save and retrieve a value from the in-memory db that play provides (Ebean is the underlying JPA implementation). Here's some sample code: @NoobDisclaimer ("I'm fairly new to Play and JPA") @Entity public class User extends Model { @Id public Long id; public String name; // Does not fetch eagerly. @ManyToOne(fetch=FetchType.EAGER) private Role role; // Role extends Model { has id and name} public static Finder<Long, User> find = new Finder<Long,

Spring : @PersistenceContext and @Autowired thread safety?

拥有回忆 提交于 2020-01-01 09:38:06
问题 based on this example : @Service public class Purchase { @PersistenceContext private EntityManager em; @Autowired private PurchaseDAO dao; private String normalField; .... // methods, operations, etc } Please help correct me if im mistaken : The service class Purchase and the PurchaseDAO are singletons that are managed by spring The service class's field normalField is not threadsafe, because singleton is a single object shared by many Let's assume the @Repository-annotated-PurchaseDAO doesnt

When using JPA entityManager why do you have to merge before you remove?

▼魔方 西西 提交于 2020-01-01 08:53:41
问题 For a while now I have been wondering why when using JPA, do I have to write my delete methods like this: @Transactional public void delete(Account account) { if (entityManager.contains(account)) { entityManager.remove(account); } else { entityManager.remove(entityManager.merge(account)); } } Perhaps the contains isn't needed since the transaction begins and ends with this method, but I still wonder why the remove couldn't just take an unmanaged object. Is it because it needs to be managed in

How do I catch the constraint violation exception from EclipseLink?

浪尽此生 提交于 2020-01-01 08:06:07
问题 I am using EclipseLink in my web application, and I am having a hard time gracefully catching and handling Exceptions it generates. I see from this thread what seems to be a similar problem, but I don't see how to work around or fix it. My code looks like this: public void persist(Category category) { try { utx.begin(); em.persist(category); utx.commit(); } catch (RollbackException ex) { // Log something } catch (HeuristicMixedException ex) { // Log something } catch