openjpa

OpenJPA - lazy fetching does not work

隐身守侯 提交于 2019-11-27 07:40:09
问题 I have a specific problem with an unit test using embedded OpenEJB container. I have a bi-directional relation between two classes. In one direction the relation works properly, but in the opposite direction the relation works only in EAGER-mode. In LAZY-mode the field section stays null. The code snipped follows: @Entity @Table(name="tracks") class TrackEntity implements Track { @Id private int trackNumber; @OneToMany(mappedBy = "track") private HashSet<SectionEntity> sections; public

websphere 7 and (application based) open-jpa 2

放肆的年华 提交于 2019-11-27 07:03:37
问题 I want to not use the built in Websphere 7 jpa plugin, instead use an application WEB-INF/lib/open-jpa 2 and a proprietary persistence provider. I cannot install the OSGI and JPA 2 feature pack for Websphere. Originally, I was getting a sax parse error simply trying to load the persistence.xml (version="2" not supported). The error was thrown by a class in open-jpa 1.2.3. When I run websphere/appserver/bin/wsjpaversion.bat, the open-jpa 1.2.3 jar is displayed. By default it overrides the open

What is referencedColumnName used for in JPA?

左心房为你撑大大i 提交于 2019-11-27 03:10:45
In JPA there is an attribute called referencedColumnName that can be set on @JoinColumn, @PrimaryKeyJoinColumn what is the idea behind this setting, can someone give a good example of where this can be used? Firo It is there to specify another column as the default id column of the other table, e.g. consider the following TableA id int identity tableb_key varchar TableB id int identity key varchar unique // in class for TableA @JoinColumn(name="tableb_key", referencedColumnName="key") "referencedColumnName" property is the name of the column in the table that you are making reference with the

JPA Criteria builder IN clause query

拜拜、爱过 提交于 2019-11-26 18:23:47
问题 How to write criteria builder api query for below given JPQL query? I am using JPA 2.2 . SELECT * FROM Employee e WHERE e.Parent IN ('John','Raj') ORDER BY e.Parent 回答1: This criteria set-up should do the trick: CriteriaBuilder cb = entityManager.getCriteriaBuilder(); CriteriaQuery<Employee> q = cb.createQuery(Employee.class); Root<Employee> root = q.from(Employee.class); q.select(root); List<String> parentList = Arrays.asList(new String[]{"John", "Raj"}); Expression<String> parentExpression

JPA/Hibernate bulk(batch) insert

点点圈 提交于 2019-11-26 18:13:27
问题 Here is simple example I've created after reading several topics about jpa bulk inserts, I have 2 persistent objects User, and Site. One user could have many site, so we have one to many relations here. Suppose I want to create user and create/link several sites to user account. Here is how code looks like, considering my willing to use bulk insert for Site objects. User user = new User("John Doe"); user.getSites().add(new Site("google.com", user)); user.getSites().add(new Site("yahoo.com",