eclipselink

Is it possible to output generated SQL using EclipseLink without having to increase log verbosity?

霸气de小男生 提交于 2019-12-17 15:25:09
问题 I want to output the SQL generated by EclipseLink to the console, during development. However, I could only do so using the logging level FINE. I have a complex domain model composed of many classes, so much that deployment takes a considerable ammount of time when the log verbosity is on the FINE level, since EclipseLink outputs its analysis of the whole model. Is there a way to get the SQL without resorting to log level FINE (like Hibernate does)? 回答1: Put the following properties in your

Why does this stream return no element?

删除回忆录丶 提交于 2019-12-17 13:02:35
问题 I tried to write the following code as a stream: AbstractDevice myDevice = null; for (AbstractDevice device : session.getWorkplace().getDevices()) { if (device.getPluginconfig().getPluginType().getId() == 1) { myDevice = device; } } this code works fine. But when I rewrite it like this it doesn't work anymore: myDevice = session.getWorkplace().getDevices().stream() .filter(s -> s.getPluginconfig().getPluginType().getId() == 1) .findFirst().get(); The Optional which I get back from the stream

stream on JPA lazy list

痴心易碎 提交于 2019-12-17 09:53:13
问题 I have JPA entity with list like this: @OneToMany(mappedBy = "scadaElement", orphanRemoval = true) private List<ElementParameter> elementParameters; and map form ElementParameter @ManyToOne @JoinColumn(name = "SCADAELEMENT_ID") ScadaElement scadaElement; when i get entity with elementParameters list and do stream on it stream do nothing, even when I trigger list with .size() but when I do the same with a for loop it work. System.out.println("elements size: " + s.getElementParameters().size())

JPA: JOIN in JPQL

怎甘沉沦 提交于 2019-12-17 09:20:45
问题 I thought I know how to use JOIN in JPQL but apparently not. Can anyone help me? select b.fname, b.lname from Users b JOIN Groups c where c.groupName = :groupName This give me Exception org.eclipse.persistence.exceptions.JPQLException Exception Description: Syntax error parsing the query Internal Exception: org.eclipse.persistence.internal.libraries.antlr.runtime.EarlyExitException Users have a OneToMany relationship with Groups . Users.java @Entity public class Users implements Serializable{

Is it possible to write a generic enum converter for JPA?

女生的网名这么多〃 提交于 2019-12-17 07:25:29
问题 I wanted to write a Converter for JPA that stores any enum as UPPERCASE. Some enums we encounter do not follow yet the convention to use only Uppercase letters so until they are refactored I still store the future value. What I got so far: package student; public enum StudentState { Started, Mentoring, Repeating, STUPID, GENIUS; } I want "Started" to be stored as "STARTED" and so on. package student; import jpa.EnumUppercaseConverter; import javax.persistence.*; import java.io.Serializable;

Is it possible to write a generic enum converter for JPA?

旧巷老猫 提交于 2019-12-17 07:25:10
问题 I wanted to write a Converter for JPA that stores any enum as UPPERCASE. Some enums we encounter do not follow yet the convention to use only Uppercase letters so until they are refactored I still store the future value. What I got so far: package student; public enum StudentState { Started, Mentoring, Repeating, STUPID, GENIUS; } I want "Started" to be stored as "STARTED" and so on. package student; import jpa.EnumUppercaseConverter; import javax.persistence.*; import java.io.Serializable;

What is referencedColumnName used for in JPA?

只愿长相守 提交于 2019-12-17 07:10:42
问题 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? 回答1: 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") 回答2:

Java/JAXB: Unmarshall Xml to specific subclass based on an attribute

一个人想着一个人 提交于 2019-12-17 05:03:43
问题 Is it possible to use JAXB to unmarshall xml to a specific Java class based on an attribute of the xml? <shapes> <shape type="square" points="4" square-specific-attribute="foo" /> <shape type="triangle" points="3" triangle-specific-attribute="bar" /> </shapes> I would like to have a List of Shape objects containing a triangle and a square, each with their own shape-specific attribute. IE: abstract class Shape { int points; //...etc } class Square extends Shape { String square-specific

JPA: @OrderColumn and visible state of an entity?

萝らか妹 提交于 2019-12-14 03:18:08
问题 This is a followup question to: Is @ManyToMany(mappedBy = ... ) + @OrderColumn supported by the JPA? I'm referring to the @OrderColumn Java docs: http://docs.oracle.com/javaee/6/api/javax/persistence/OrderColumn.html The text there is the same as what the JPA 2 spec writes in section 11.1.39 OrderColumn Annotation . What does the part "the order column is not visible as part of the state of the entity" mean exactly ? There's a lot of room for interpretation on that. Does that mean the order

jpa: when merging many to many previous record gets deleted

有些话、适合烂在心里 提交于 2019-12-14 01:56:08
问题 i have a Users and Tags table,and also a user_tag_xref table that holds the many to many relationship.now netbeans generates the entity classes for me (using eclipselink) below is the entity mapping relationship on User class @ManyToMany(mappedBy = "usersList") private List<Tags> tagsList; on Tags class @JoinTable(name = "USERS_TAG_XREF", joinColumns = { @JoinColumn(name = "TAG_ID", referencedColumnName = "TAG_ID")}, inverseJoinColumns = { @JoinColumn(name = "USER_ID", referencedColumnName =