persistence

JPA 2 CriteriaQuery, using a limit

﹥>﹥吖頭↗ 提交于 2019-12-28 03:51:11
问题 I am using JPA 2. For safety reasons, I am working type safe with CriteriaQuery's (and thus, I am not searching for any solutions to typed queries and so on). I recently came across an issue in which I needed to set a SQL-LIMIT. After a lot of searching, I was still not successful in finding a solution. CriteriaQuery<Product> query = getEntityManager().getCriteriaBuilder().createQuery(Product.class); Root<Product> product = query.from(Product.class); query.select(product); return em

JPA Map<String,String> mapping

泄露秘密 提交于 2019-12-28 02:51:44
问题 How can I map a Map in JPA without using Hibernate's classes? 回答1: Does not the following work for you? @ManyToMany(cascade = CascadeType.ALL) Map<String,EntityType> entitytMap = new HashMap<String, EntityType>(); EntityType could be any entity type, including a String . 回答2: Although answer given by Subhendu Mahanta is correct. But @CollectionOfElements is deprecated. You can use @ElementCollection instead: @ElementCollection @JoinTable(name="ATTRIBUTE_VALUE_RANGE", joinColumns=@JoinColumn

Run C# application at Windows startup?

℡╲_俬逩灬. 提交于 2019-12-26 23:12:43
问题 It's all the day that I'm trying to implement a startup feature into my project. I used Registry key: //Computer\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run (Administrator Rights) I used Registry key: //Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run (Administrator Rights) The code work but when I restart the computer nothing happens. This is the code I used. RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\

Run C# application at Windows startup?

非 Y 不嫁゛ 提交于 2019-12-26 23:09:34
问题 It's all the day that I'm trying to implement a startup feature into my project. I used Registry key: //Computer\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Run (Administrator Rights) I used Registry key: //Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run (Administrator Rights) The code work but when I restart the computer nothing happens. This is the code I used. RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\

no leveldbjni64-1.8 in java.library.path exception while running akka project

为君一笑 提交于 2019-12-25 09:45:03
问题 I am trying to start an existing project from the main class. But getting the exception below. java.lang.UnsatisfiedLinkError: Could not load library. Reasons: [no leveldbjni64-1.8 in java.library.path, no leveldbjni-1.8 in java.library.path, no leveldbjni in java.library.path, C:\Users\Z003SXSP\AppData\Local\Temp\leveldbjni-64-1-386410980806513791.8: Can't find dependent libraries] But when I tried running the same project from other machine, I am able to run it successfully also found

no leveldbjni64-1.8 in java.library.path exception while running akka project

Deadly 提交于 2019-12-25 09:44:31
问题 I am trying to start an existing project from the main class. But getting the exception below. java.lang.UnsatisfiedLinkError: Could not load library. Reasons: [no leveldbjni64-1.8 in java.library.path, no leveldbjni-1.8 in java.library.path, no leveldbjni in java.library.path, C:\Users\Z003SXSP\AppData\Local\Temp\leveldbjni-64-1-386410980806513791.8: Can't find dependent libraries] But when I tried running the same project from other machine, I am able to run it successfully also found

JPA Map<String,String[]> mapping

半城伤御伤魂 提交于 2019-12-25 06:37:24
问题 How can I map a Map in JPA without using Hibernate's classes? public Map<String, String[]> parameters = new HashMap<String, String[]>(); Thanks in advance. 回答1: An example implementation: @Entity @Table(name = "MAP") //optional public class Parameters { @Id @Column(name = "\"KEY\"") //optional private String id; @ElementCollection @CollectionTable( //optional name = "MAP_VALUES", joinColumns = { @JoinColumn(name="MAP_KEY") } ) private Collection<String> collection; public Parameters() { }

Lazy loading (one to one using FK) issue

时间秒杀一切 提交于 2019-12-25 04:39:13
问题 when executing session.createQuery("from Author").list(); The associated book instance info is loaded eagerly even when relationship is marked optional=false,fetch type = lazy from Author->book as per below generated sql's. I have this relationship as one to one just for understanding purposes, and not one to many at the moment. Is it possible to make it lazy from Author-Book, if so not sure what I am missing? Hibernate: select author0_.AUTHOR_ID as AUTHOR_I1_0_, author0_.email as email2_0_,

Batch updates in JPA (Toplink)

和自甴很熟 提交于 2019-12-25 04:17:43
问题 Is there any way if executing batch updates (EntityManager persist() or merge()) using JPA Toplink? 回答1: If you want to do a batch update, you can create a Query (either JPQL or Native SQL) that performs the update using the EntityManager, and then call executeUpdate on that query. 来源: https://stackoverflow.com/questions/7365325/batch-updates-in-jpa-toplink

QDataStream unable to serialize data

可紊 提交于 2019-12-25 04:10:53
问题 I am trying to follow the tutorial here and serialize Qt objects. Here is my code: QFile file("/Users/kaustav/Desktop/boo.dat"); if (!file.open(QIODevice::WriteOnly)) { qDebug() << "Cannot open file for writing: " << qPrintable(file.errorString()) << endl; //no error message gets printed return 0; } QDataStream out(&file); // we will serialize the data into the file out.setVersion(QDataStream::Qt_5_3); //adding this makes no difference out << QString("the answer is"); // serialize a string