jpa-2.0

JPA entity giving error on implementing Bill of material concept

谁说我不能喝 提交于 2019-12-08 04:32:30
问题 Trying to implement the Bill of Material concept using JPA entity:- IDE: Eclipse Helios; Jars: eclipselink2.4.0 , javax.persistence Entity is as follows: @Id @TableGenerator(name = "Config_Key_Incrementor", table = "id_generator", pkColumnName = "gen_name", valueColumnName = "gen_value", pkColumnValue = "conifg_id_gen", allocationSize = 1, initialValue = 1) @GeneratedValue(strategy = TABLE, generator = "Config_Key_Incrementor") @Column(name = "config_id") private int configId; @Column(name =

Execute some arbitrary sql in the current transaction in JPA 2.0

情到浓时终转凉″ 提交于 2019-12-08 03:31:12
问题 I am new to JPA 2.0/EclipseLink/Glassfish/JEE6, and have kind of a basic question. I have a DAO in which most of the entities are mapped directly to columns using JPA annotations, so I use the EntityManager, and it works great with no issues. However there are some tables in which I am constructing the SQL statements myself b/c they use oracle-specific functions (spatial), and I want very fine-grained control of the SQL. So I am building it with string concatenation. I would like to be able

JSF 2 OpenJPA 2 Glassfish 3.1 WEB9031 Error

此生再无相见时 提交于 2019-12-08 03:30:27
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 org.glassfish.web.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1410) at org.glassfish.web

“org.hibernate.TypeMismatchException: Provided id of the wrong type” when using @OneToOne for a bi-directional relation

不想你离开。 提交于 2019-12-08 03:16:51
问题 I don't succeed in using @OneToOne when the composite primary key is the same in both classes: @Entity public class One implements Serializable { private static final long serialVersionUID = 1L; @EmbeddedId private OnePK onePK; @OneToOne(cascade = CascadeType.ALL, mappedBy = "one") private Two two; //... constructors, getters and setters } @Entity public class Two implements Serializable { private static final long serialVersionUID = 1L; @EmbeddedId private TwoPK twoPK; @JoinColumns({

Spring 3.1 JPA not inserting data while running in tomcat

假如想象 提交于 2019-12-08 02:43:47
问题 I have spent three days trying to find the solution to this problem to no avail. I am desperate to figure this out. I have a simple spring app, running in servlet 2.5 with jstl tags 1.2, running in tomcat with spring 3.1, using hibernate and the hibernate jpa implementation. I can list data from a page, but I cannot complete an insert. The record goes back, it appears to fire through with no problems. Yet no insert takes place. I know there are other posts similar but I have looked through

How to use EntityManager from @PrePersist?

折月煮酒 提交于 2019-12-08 02:20:37
问题 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,

Glassfish: Silently ignore unavailable data source at application start up

自作多情 提交于 2019-12-08 02:15:37
问题 I have an EJB application which uses JPA 2.0 on Glassfish 3.1.2 (provider is EclipseLink). When the database is down the application does not start and even more: can't be deployed. This is because EclipseLink does some initial verification. Is there a way that the application can be deloyed and started even if the database is down? Background: The resource being unavailable comes not into play until the first business function is called which accesses the database. From application startup

order-by-using-search-string - JPA

六眼飞鱼酱① 提交于 2019-12-08 02:15:16
问题 hey i'm looking for way to search for text pattern (in jpa) and to sort the result, first all the result starting with this string and then all other result. i have found Mysql order by using search string to get the answer for mysql most of the answers use union (which does not exist in jpa ) and force to query the db or open a view for that. (ordering from code is not that good solution since we use paging to get part of the result as the result size can be really big) One solution i like

Retrieve primary key column definition of a generic entity in JPA

China☆狼群 提交于 2019-12-08 01:38:51
问题 Let say I have a generic method using JPA to list out entities public <T> List<T> list(Class<T> entity) throws Exception { List<T> result = new ArrayList<T>(); CriteriaBuilder builder = em.getCriteriaBuilder(); CriteriaQuery<T> query = builder.createQuery( entity ); Root<T> root = query.from( entity ); query.select( root ); //possible? query.orderBy(builder.asc(...)); result = em.createQuery( query ).getResultList(); return result; } Is there anyway for us to add orderby to the query and make

Map's entries to separate columns in Hibernate

旧巷老猫 提交于 2019-12-08 01:16:17
问题 Suppose I have a Players table: ID | name | email | age | ... 1 | 'bob' | null | 23 | ... There is a lot of columns (say, 50) and each (apart from ID ) might be null. Please disregard the table design, it's has to stay this way for now :-( I'd want to map this table to an entity (i.e. i'd like it to work for both saving and reading): public class Player implements Serializable { private Map<String, String> attributes; // more code, ctor, setters, getters etc... } where each column in the