eclipselink

JPA - Persisting a Unidirectional One to Many relationship fails with EclipseLink

耗尽温柔 提交于 2019-12-03 19:01:13
问题 I'm trying to persist a very simple Unidirectional One to Many relationship, but EclipseLink (2.3.1) fails. Service Class (Parent): @Entity @Table(name = "tbl_service2") public class Service implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name="service_id") public long serviceID; @Column(name="name") public String name; @OneToMany(cascade={CascadeType.ALL}) @JoinColumn(name="service_id", referencedColumnName="service_id") public Set<Parameter>

JPA / EclipseLink - create script source with one SQL statement taking multiple lines

余生长醉 提交于 2019-12-03 17:23:08
问题 I want to let the persistence provider (EclipseLink 2.5.0) automatically create the tables in the, already existing, database by using the persistence unit property "javax.persistence.schema-generation.create-script-source" and a valid SQL-DDL-script. persistence.xml: <property name="javax.persistence.schema-generation.create-script-source" value="data/ddl.sql"/> ddl.sql: USE myDatabase; CREATE TABLE MyTable ( id INTEGER NOT NULL AUTO_INCREMENT, myColumn VARCHAR(255) NOT NULL, PRIMARY KEY (id

Configuration of eclipselink + Spring MVC + MySql using Java Configuration (No XML configuration)

喜你入骨 提交于 2019-12-03 17:08:37
I am trying to integrate eclipselink JPA into my Spring Web application. Is there any good guide oh how to configure eclipseLink for MySql database in Spring MVC using Java based configuration only? . No dispatcher-servlet.xml. I am familiar with Java based Spring configuration. (Using @Configuration, @EnableWebMvc, @ComponentScan, @EnableTransactionManagement etc). But not familiar with eclipseLink java based configuration in Spring MVC. Following is the pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http:/

Eclipselink history of related objects

核能气质少年 提交于 2019-12-03 15:38:47
I can create history of an entity with a HistoryCustomizer @Entity @Customizer(MyHistoryCustomizer.class) public class Employee {..} the HistoryCustomizer is something like this one: public class MyHistoryCustomizer implements DescriptorCustomizer { public void customize(ClassDescriptor descriptor) { HistoryPolicy policy = new HistoryPolicy(); policy.addHistoryTableName("EMPLOYEE_HIST"); policy.addStartFieldName("START_DATE"); policy.addEndFieldName("END_DATE"); descriptor.setHistoryPolicy(policy); } } The history objects can be fetched with the "AS_OF" hint javax.persistence.Query

jndi database connection with jpa and eclipselink

拈花ヽ惹草 提交于 2019-12-03 13:46:45
I try to setup a database connection in java with JNDI in combination with eclipseLink/JPA on Tomcat 5.5. I already configured the JNDI resource in web.xml and context.xml. The db connection works with JNDI without using JPA and eclipseLink. After configuring the persistence.xml for eclipseLink, I got the following exception. I don't know how to configure the persistence.xml correctly to use JNDI datasource for the db connection. The exception WicketMessage: Method onFormSubmitted of interface org.apache.wicket.markup.html.form.IFormSubmitListener targeted at component [MarkupContainer

EclipseLink JPA - location of persistence.xml

不打扰是莪最后的温柔 提交于 2019-12-03 13:13:43
I am using JPA for a java class and having trouble putting the persistence XML file where it should be. The IDE i am using is Eclipse Helios. Eclipselink jar files are downloaded and added to my JRE System Library and all. I wrote up the persistence.xml with the tag after getting the following error : Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named customers Provider tag: <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> The program still doesn't run so i am wondering where should I place persistence.xml (i.e

Unknown entity class error message even though the entity is marked with @Entity annotation

丶灬走出姿态 提交于 2019-12-03 13:07:13
I am building REST web app using Netbean6.9.1 and JPA EclipseLink. The issue I'm facing is even though my entity class MasatoTable is marked with Entity annotation, I get error: (java.lang.IllegalArgumentException: Unknown entity bean class: class entity.MasatoTable, please verify that this class has been marked with the @Entity annotation.) The thing is when I restart the GlassFish3 server from NetbeanIDE, it works for a while and somehow at some point, the error start showing up. I used to use Toplink Essential and had no issue but I've changed to EclipseLink and re-defiend persistence.xml

How to know what JAXB implementation is used?

限于喜欢 提交于 2019-12-03 11:55:52
I am using MOXy as JAXB Implementation but somehow I would like to show the Implementation Name (e.g. Moxy) and the version number on some admin screen (dynamically). How can I retrieve that info from JAXB? Cheers You could do something like the following to figure out the JAXB impl being used: import javax.xml.bind.JAXBContext; public class Demo { private static final String MOXY_JAXB_CONTEXT = "org.eclipse.persistence.jaxb.JAXBContext"; private static final String METRO_JAXB_CONTEXT = "com.sun.xml.bind.v2.runtime.JAXBContextImpl"; public static void main(String[] args) throws Exception {

Entity must be managed to call remove

巧了我就是萌 提交于 2019-12-03 11:50:54
What's going on here? @Stateless @LocalBean public class AppointmentCommentDao { public void delete(long appointmentCommentId) { AppointmentComment ac = em.find(AppointmentComment.class, appointmentCommentId); if (ac != null) { em.merge(ac); em.remove(ac); } } @PersistenceContext private EntityManager em; } On the call to remove I get an IllegalArgumentException with the message being Entity must be managed to call remove: ...., try merging the detached and try the remove again. In your case merge is not needed, because ac is not deattached in any point between em.find and em.remove . In

No [EntityType] was found for the key class […] in the Metamodel

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 11:10:42
Entity: @Entity @Table(name="user_account") public class UserAccount implements Serializable{ private static final long serialVersionUID = -2606506548742732094L; @Id @GeneratedValue(strategy=GenerationType.TABLE) private Integer id; persistence.xml <persistence-unit name="Maze" transaction-type="RESOURCE_LOCAL"> <exclude-unlisted-classes>false</exclude-unlisted-classes> <properties> <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/> <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/mazedb"/> <property name="javax.persistence.jdbc.user"