jpa-2.0

AbstractMethodError when creating typed query with Hibernate 3.6.3 and JPA 2.0

泪湿孤枕 提交于 2019-12-06 02:41:34
I'm using Hibernate and JPA for a small project. Somehow when trying to obtain an typed Query, the java.lang.AbstractMethodError: org.hibernate.ejb.EntityManagerImpl.createQuery(Ljava/lang/String;Ljava/lang/Class;)Ljavax/persistence/TypedQuery is thrown; org.hibernate.ejb.EntityManagerImpl is from hibernate-entitymanager-3.3.2.GA.jar . This is not okay throwing the above exception: public Account read(Account entity) { EntityManager em = ManagedEntityManagerFactory.getEntityManager(); String jpql = JPQLGenerator.readAccount(); TypedQuery<Account> typedQuery = em.createQuery(jpql, Account.class

Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property:

萝らか妹 提交于 2019-12-06 01:36:46
@Entity public class Purveyor implements Serializable { /** * */ private static final long serialVersionUID = 1L; @Id @GeneratedValue(strategy = GenerationType.AUTO) private int ref_purveyor; @Column(unique = true) private String purveyor_name; @Column(unique = true) private int purveyor_number; @Column(unique = true) private String adress; @Column(unique = true) private int fax; /** * * @return This returns the purveyor's ID. */ public int getRef_purveyor() { return ref_purveyor; } /** * * @param ref_purveyor * This refers to the ID of the new purveyor. */ public void setRef_purveyor(int ref

Learning resource for Configuring Hibernate JPA 2.0 on Glassfish server

北慕城南 提交于 2019-12-06 00:39:44
I am trying to create a new Java EE project using hibernate and JPA 2.0 on the glass fish server. Can you guys provide me some resources to configure the above so that they work seamlessly? I have tried using netbeans and generated the persistence unit by using the hibernate provider, but I end up getting this error: javax.persistence.PersistenceException: [PersistenceUnit: DBAppPU] Unable to build EntityManagerFactory Pascal Thivent First, install Hibernate support via the update tool (or follow the manual procedure ). Second, provide a JPA 2.0 persistence.xml to use Hibernate as JPA provider

JPA OneToOne bidirectional .

旧街凉风 提交于 2019-12-05 23:39:23
问题 I have two entity classes that are in @OneToOne relation. The example code are as follow: public class A { @Id private int id; private String name; @JoinColumn(name = "B_ID", referencedColumnName = "id") @OneToOne(cascade=CascadeType.ALL) private B b; //setters and getters } public class B { @Id private int id; private String name; @OneToOne(mappedBy="b") private A a; //setter and getters } my question here is "Can I use setA(A a) method in class B. I mean like this . . em.getTransaction()

Dedicated cache region for entity subclasses?

爱⌒轻易说出口 提交于 2019-12-05 20:41:58
问题 We have an extensive entity model with 100+ entity classes. All the entity classes are subclasses of a single entity superclasses. The shared cache mode has been set to ALL . @Entity @Inheritance(strategy = InheritanceType.JOINED) @Table(name = "entities") public abstract class LongIdEntity { @Id @GeneratedValue(strategy = GenerationType.TABLE) private Long id; @Version @Column(name = "OPT_LOCK_VERSION") private Long lockVersion; etc... } An example subclass: @Entity @Table(name = "cars")

Lazy loading exception when using JSF Converter (refering to a collection)

廉价感情. 提交于 2019-12-05 18:34:26
This is my first post after many research on this problem. This example is running under Jboss 7.1 with seam 3.1 (solder + persistence + faces) with seam managed persistence context I'm facing a problem, the classical failed to lazily initialize a collection, no session or session was closed: org.hibernate.LazyInitializationException: failed to lazily initialize a collection, no session or session was closed when using a converter on Entity beans. The aim is to stay 100% Object oriented, by reusing the JPA model. in beans.xml, org.jboss.seam.transaction.TransactionInterceptor is activated

Hibernate entities without underlying tables

China☆狼群 提交于 2019-12-05 17:48:14
问题 I have a really ugly legacy database system that I need to integrate with. Essentially I'm doing some read only reporting on the system, and I don't want to set up a thousand entities representing each of the tables that I'm working on. Instead, I'd like to just define an Entity for each of the report-types that I generate (essentially a union of a bunch of columns from different tables), and then let hibernate map from the nasty (many joined, many unioned) sql query to a list of such

No transaction in progress exception with Spring 3.1 and JPA 2

不问归期 提交于 2019-12-05 17:20:35
I have been at this for weeks. I have tried eclipselink and now just plain JPA. I keep getting the same issue. Everytime I try to flush my entity manager I get 'javax.persistence.TransactionRequiredException: no transaction is in progress' exception. I know its something to do with how I have everything wired but I can't figure it out. I have tried writing JUnit tests to test, but since I am new to spring that has a entirely different set of issue. Some things to note: I am not using a persistence.xml since I am using spring 3.1 * App Server: WebSphere 8.5 (Liberty Profile) * exception [ERROR

Is it possible for a JPA embeddable to contain Embeddable or Collection of Embeddables?

亡梦爱人 提交于 2019-12-05 16:44:34
问题 I wonder whether it is possible to have an ElementCollection of Embeddable inside another Embeddable ? Here's an example of my Supplier entity which has a list of Addresses, which is of an embeddable type : @Entity public class Supplier extends BaseCommonEntity { @Column(unique=true) private String supplierCode; private String supplierName; @ElementCollection private List<Address> addresses; .... And here's my embeddable Address that contains a list of embeddable Phone @Embeddable public

Is it possible to map a map<String,List<Entity>> in JPA?

↘锁芯ラ 提交于 2019-12-05 14:15:09
I'm thinking if i use maps like Map<String,List<Entity>> or Map<Long,List<Entity>> it will help me with a few things, but I couldn't find any example to map that kind of map. My question is, is it possible to do that kind of mapping in JPA standards, and what kind of annotation I should use? Yes, it's possible to create either of those Maps. Why not try it and answer your own question? It would be faster than passively asking here. As for JPA, I would suggest a better abstraction than a Map for holding onto that data. This feels too generic for me. That might be what you're going for, but JPA