eclipselink

Hibernate or EclipseLink for JPA? [closed]

孤街醉人 提交于 2019-12-31 17:52:11
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed last year . I was wondering if anyone has experience with the JPA2.0 implementation of any of those frameworks? Especially together with Spring3.x which comes with EclipseLink support. Do you use any of those frameworks and JPA2.0 for production? Any severe issues? 回答1: IMHO It is always

Hibernate or EclipseLink for JPA? [closed]

点点圈 提交于 2019-12-31 17:50:15
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed last year . I was wondering if anyone has experience with the JPA2.0 implementation of any of those frameworks? Especially together with Spring3.x which comes with EclipseLink support. Do you use any of those frameworks and JPA2.0 for production? Any severe issues? 回答1: IMHO It is always

CacheRetrieveMode.BYPASS of EclipseLink is not useful

陌路散爱 提交于 2019-12-30 12:14:48
问题 Follow my code: Company cc = em.find(Company.class, clientUser.getCompany().getId()); System.out.println(cc.getCompany_code()); HashMap findProperties = new HashMap(); findProperties.put(QueryHints.CACHE_RETRIEVE_MODE, CacheRetrieveMode.BYPASS); Company oo = em.find(Company.class, clientUser.getCompany().getId(), findProperties); System.out.println(oo.getCompany_code()); Just like the example "Used as EntityManager properties". here But, there are nothing different between the two outputs.

Lazy loading does not works for ManyToOne in eclipselink

落花浮王杯 提交于 2019-12-30 06:59:32
问题 Address has many-to-one relationship with person like : Person : @Id @Column(name="personid") private Long personId; private String firstName; private String lastName; private String email; @OneToMany(cascade = CascadeType.ALL,mappedBy="person",targetEntity=Address.class,fetch=FetchType.LAZY) private List addressArray=new ArrayList<>(); public Person() { } and Address : @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name="personId") private Person person; I want to access person's firstname

Merging a managed entity on the @ManyToOne side

妖精的绣舞 提交于 2019-12-30 06:45:30
问题 Given below a one-to-many relationship from Department to Employee . Department (parent) : @OneToMany(mappedBy = "department", fetch = FetchType.LAZY, cascade = CascadeType.ALL) private List<Employee> employeeList = new ArrayList<Employee>(0); Employee (child) : @JoinColumn(name = "department_id", referencedColumnName = "department_id") @ManyToOne(fetch = FetchType.LAZY, cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH, CascadeType.DETACH}) private Department department;

JPQL: Enum literal in SELECT NEW query

纵然是瞬间 提交于 2019-12-30 06:34:46
问题 I have a descriptor class for a couple of domain classes. The descriptor class has a field 'type' which is an enum and indicates the type of the domain class. In some queries I want to return on or more descriptors and pass the type as constructor argument. So my idea was to pass it as a query parameter: String jpql = "SELECT NEW model.ModelDescriptor" + "(t.id, t.name, t.description, :modelType) ... "; TypedQuery<ModelDescriptor> query = em.createQuery(jpql, ModelDescriptor.class); query

IN clause with a composite primary key in JPA criteria

坚强是说给别人听的谎言 提交于 2019-12-30 06:27:10
问题 I have a table named group_table in MySQL with only two columns user_group_id and group_id (both of them are of type VARCHAR ). Both of these columns together form a composite primary key. I need to execute a statement using a sub-select IN() to select rows based on a list of values passed to the query. @Override @SuppressWarnings("unchecked") public List<GroupTable> getList(List<GroupTable> list) { CriteriaBuilder criteriaBuilder=entityManager.getCriteriaBuilder(); CriteriaQuery<GroupTable>

OneToMany - what are the differences between join table and foreign key?

£可爱£侵袭症+ 提交于 2019-12-30 04:29:04
问题 There is the possibility to disable the @OneToMany relationship join table with the @JoinColumn annotation. The default is a join table. What are the advantages and disadvantages for a production system for example? When should I use a join table and when not? Thank you. 回答1: By default @OneToMany will create a join table only if you'll use unidirectional relationship . In other words, if you have Employee and Project entities and the Employee entity is defined as follows (assume there is no

JPA - Is there a way/method to retrieve Persistence Unit information

对着背影说爱祢 提交于 2019-12-29 08:55:25
问题 I'd like to find out my data source name in the code. Is there a way of doing that? I am using eclipselink. thanks To be more specific, my aim is to get an jdbc connection object. I know i can do that thru: datasource = (DataSource) (new InitialContext()).lookup("my_data_source_name") connection = dataSource.getConnection(); But I don't want to hard code the data source name in my code. I also tried java.sql.Connection connection = em.unwrap(java.sql.Connection.class); and it always return

Perform UPDATE without SELECT in eclipselink

不羁岁月 提交于 2019-12-29 06:29:08
问题 Is is possible (without writing custom SQL) to have Eclipselink trust me as to whether to perform an update or insert on a merge, rather than perform a select, then an update or insert? If so, how? In my mind I'd like to use a transient flag and a custom if statement to determine whether the item is already in the database or not, and instruct eclipselink to perform the query required. I understand Hibernate provides this as update() and save() A few notable points: I have a large amount of