jpa-2.0

No transaction in progress exception with Spring 3.1 and JPA 2

二次信任 提交于 2019-12-22 08:39:38
问题 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

Select … in equivalent in JPA2 criteria

情到浓时终转凉″ 提交于 2019-12-22 08:12:13
问题 Is there any way to perform a query like the following using JPA2 criteria APIs? select a from b where a in (1, 2, 3, 4) There's a way to do that using plain Hibernate, but we can't find anything like that in JPA2. 回答1: Yes JPA 2 Critera supports returning a specific field from a entity and using a where clause which includes an in clause. I have included an example below which takes a JPQL and converts it to a similar JPA 2 Criteria-based option. JPQL: select b.a from B b where a in (1, 2, 3

From which version on will Hibernate support JPA 2.2?

我的梦境 提交于 2019-12-22 07:04:59
问题 As Java EE 8 including JPA 2.2 was released this summer it's good to know when Hibernate will support it. Hibernate 5.2 is mentioned to support JPA 2.1. Hibernate 6.0 roadmap doesn't have any references to JPA 2.2 support. Thanks. 回答1: I know this is an old(ish) question, but according to their website the 5.3 "series" will support JPA 2.2. However, as of the posting of this answer it seems the 5.2 series is still the latest stable release. Update (June 8, 2018) As helpfully mentioned by

Using @ElementCollection in CriteriaQuery (or Querying over the content of an @ElementCollection)

六眼飞鱼酱① 提交于 2019-12-22 05:24:15
问题 public enum ReportStatus { SUCCCEED, FAILED; } public class Work { @ElementCollection @Enumerated(EnumType.STRING) List<ReportStatus> reportStatuses; } Given the following structure, I'd like to perform a query to find all the work filtered by reportStatuses. It works fine with the following hql syntax : public List<Long> queryHQL() { final String query = "SELECT w.id FROM Work w JOIN w.reportStatuses s WHERE s in (:rs)"; final List<ReportStatus> reportStatuses = new ArrayList<ReportStatus>()

What do i get from setting this TransactionAttributeType.NOT_SUPPORTED

对着背影说爱祢 提交于 2019-12-22 04:41:35
问题 I happen to find examples that uses this construct though I am not sure what can I get from this? Does it means that all select statements in a stateless EJB should follow this? @Stateless public class EmployeeFacade { @PersistenceContext(unitName="EmployeeService") EntityManager em; @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public List<Department> findAllEmployees() { return em.createQuery("SELECT e FROM Employee e", Employee.class) .getResultList(); } What do I get from

Maven archetypes for OpenJPA

元气小坏坏 提交于 2019-12-21 21:57:47
问题 Greetings. I'm just starting to explore Maven and I use m2eclipse as to use Maven in Eclipse. I found that there is a hibernate-based archetype with Group Id: com.rfc.maven.archetypes and Artifact Id: jpa-maven-archetype Does anybody knows if there are archetypes for OpenJPA-based projected with test frameworks included? Thanks a lot. 回答1: Does anybody knows if there are archetypes for OpenJPA-based projected with test frameworks included? Not to my knowledge. So my suggestion would be to use

Using Ebean/JPA in my Play application, how can I delete an object in a OneToOne relationship?

旧街凉风 提交于 2019-12-21 21:56:15
问题 I have the following classes: import play.db.ebean.Model; import javax.persistence.*; @Entity public class A extends Model { @Id private int id; /* Other irrelevant properties */ @OneToOne(cascade = CascadeType.ALL, optional = true) private B b; } import play.db.ebean.Model; import javax.persistence.*; @Entity public class B extends Model { @Id private int id; /* Other irrelevant properties */ @OneToOne(mappedBy = "b") private A a; @OneToOne(cascade = CascadeType.ALL, optional = false)

JSF 2 reusing the validation defined in the JPA entities?

若如初见. 提交于 2019-12-21 20:57:40
问题 Let's start with an example : In my JPA entity public class User { @Pattern("^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$", message="invalidEmailResourceBundleKey") private String email; @Min(5, message="minimumResourceBundleKey") private int age; ... } In my JSF Bean public class UserBean { private User user; // do i have to redefine it here, since it's already a part of the user ? @@Pattern("^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA

JPA 2.0 in WebLogic Server 10.3.6

最后都变了- 提交于 2019-12-21 20:38:25
问题 I need to use JPA 2.0 (with the EclipseLink implementation). The problem is that I also need to deploy this app in a WebLogic 10.3.6 server, which implements the Java EE 5 specification, and so, it is not required to support JPA 2. I know that there are patches that can be used to add support for JPA 2.0 in this version, but the sysadmin doesn't want to change anything in the server at all I tried adding the javax.persistence-2.1.0.jar file to my war thinking that my app would just use this

Hibernate does not delete orphans on OneToMany

社会主义新天地 提交于 2019-12-21 15:46:30
问题 I have the following pretty simple one to many relations: Team has a Set of players: @Entity(name = "TEAM") @Access(AccessType.PROPERTY) public class Team{ private Integer id; private String name; private Set<Player> players ; @Id @Column(name = "id") public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } @Column(name = "team_name") public String getName() { return name; } public void setName(String name) { this.name = name; } @OneToMany(cascade = {CascadeType