eclipselink

java.time YearMonth as a type within entity

随声附和 提交于 2019-12-22 12:25:35
问题 How do you use YearMonth within an entity? I have seen a lot of stack overflow answers about a converter? Is this still needed and if so how? @Basic(optional = false) @NotNull @Column(name = "cc_exp_date") private YearMonth ccExpDate; The exception I am getting is below. Could I just convert this into a date within the set method and convert back to YearMonth within the get method of the entity as a work around? MysqlDataTruncation: Data truncation: Incorrect date value: '\xAC\xED\x00\x05sr

JPA update many-to-many deleting records

女生的网名这么多〃 提交于 2019-12-22 11:24:01
问题 I have a @ManyToMany relationship between two entities. When I perform an update on the owning side, it appears that JPA deletes all the linked records from my database and re-inserts them. For me this is a problem because I have a MySQL trigger that fires before a record is deleted. Any ideas on how to get around this problem? @Entity public class User { @Id @Column(name="username") private String username; ... @ManyToMany @JoinTable(name="groups", joinColumns= @JoinColumn(name="username",

JPA Eclipselink getting wrong sequence number

岁酱吖の 提交于 2019-12-22 10:07:53
问题 I'm using some Entities mapped to Oracle DB-Tables. For ID-Generation I'm using a sequence generator annotated as following: @Id @SequenceGenerator(name = "SEQ_RULES", sequenceName = "SEQUENZ_RULES") @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_RULES") @Column(name = "SERIALNO") protected Long serialno; During programm execution I make a new Instance from my Entity and want to persist this generated one. After restart of the database I'm getting wrong sequence numbers

EclipseLink: Query to MappedSuperclass fails

拥有回忆 提交于 2019-12-22 09:56:33
问题 My application is a store selling fishes, aquariums etc. I want to get a list of top 10 items among all the items based on sales count. I use the following class: @MappedSuperclass @NamedQueries({ @NamedQuery(name="getTopItems",query="SELECT x FROM FishStoreItem x ORDER BY x.salescnt DESC, x.title DESC") }) public abstract class FishStoreItem extends DomainSuperClass implements Serializable { ...... } Problem is in the following exception: Exception [EclipseLink-8034] (Eclipse Persistence

Is there how I could programmatically ask eclipselink to drop and create all tables?

不羁岁月 提交于 2019-12-22 09:48:08
问题 This helps in unit testing. 回答1: The following should work for you: ServerSession session = entityManager.unwrap(ServerSession.class); SchemaManager schemaManager = new SchemaManager(session); schemaManager.replaceDefaultTables(true, true); 回答2: One way to do that is to execute the sql scripts eclipselink generates specifying: <property name="eclipselink.ddl-generation.output-mode" value="both"/> in persistence.xml 来源: https://stackoverflow.com/questions/3746572/is-there-how-i-could

EJB Glassfish v3.1.2 client passed data to session bean is always null

本小妞迷上赌 提交于 2019-12-22 09:45:31
问题 I am having a problem when calling session bean method passing method parameters from client application, the data reaches the method call is always null or set to default value. while the process of the method works well with the object for example: -we have method to persist an object entity addStudent(Student student); - from the client we create the student object setting student fields like student name and so on, calling the method addStudent(ourStudent); this ourStudent reaches method

JPA: How to get Id after persist in standalone java app

血红的双手。 提交于 2019-12-22 09:43:43
问题 This is a standalone java application, not web application. So when I persist the object like this public <T> T create(T t) { em.getTransaction().begin(); em.persist(t); em.flush(); em.getTransaction().commit(); return t; } The id inside the T t object is still null, even though a new row with correct data and id is created correctly inside the database. Usually in my web app that utilize @EJB , the id available right after I persist, since it persist the entity object into my persistence

Set Isolation level in eclipselink

做~自己de王妃 提交于 2019-12-22 08:45:28
问题 I would like to set isolation level using eclipse link, I tried these 2 ways to do it: java.sql.Connection mgr = EMF.get().createEntityManager(); tx = mgr.getTransaction(); tx.begin(); java.sql.Connection connection = mgr.unwrap(java.sql.Connection.class); connection.setTransactionIsolation(java.sql.Connection.TRANSACTION_READ_COMMITTED); System.out.println("Connection: "+connection.getTransactionIsolation()); //prints TRANSACTION_READ_COMMITED as expected org.eclipse.persistence.sessions

JPA: Left join not working with “is null” in where clause

时光怂恿深爱的人放手 提交于 2019-12-22 08:17:38
问题 I am using EclipseLink (2.4, 2.5 and 2.6) on a very simple project where I have a Department entity and each Department links to an Employee entity which is the manager of the Department . I am currently unable to make this simple query work: select d from Department d where d.manager is null Returns 1 row select d from Department d left join fetch d.manager where d.manager is null Returns 0 row I am using Eclipselink over an H2 database. The SQL query generated does not seem to create a left

Exception: Must start with Java agent to use InstrumentationLoadTimeWeaver. See Spring documentation

ぐ巨炮叔叔 提交于 2019-12-22 08:07:03
问题 I'm getting exception when trying to execute test Please help . Thank you in advance I'm using : Java 7 , EclipseLink 2.5.0-SNAPSHOT, Spring 3.2.4 Test configuration file : <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" p:location="classpath:jdbc.properties" /> <bean id="tttDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource" p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.url}" p:username="$