eclipselink

JPA Many to Many Relationship Creates Two Join Tables

蹲街弑〆低调 提交于 2020-01-04 14:18:08
问题 I am trying to create a many-to-many relationship between User and FileObject classes with the assumption user can access many file objects and file object can be accessed by many user and one-to-many relationship as one user can own many files but one file can only be owned by one user. Here is my code: @Entity public class User { @Id @GeneratedValue(strategy = GenerationType.TABLE) public int id; public String firstname; public String lastname; public String publicAttributes; public String

Specifying the MOXy runtime for multiple Java packages

人盡茶涼 提交于 2020-01-04 04:37:27
问题 Is there a way to specify MOXy as my JAXB implementation, for domain classes spread across multiple Java packages, other than putting jaxb.properties into every single package? 回答1: To specify EclipseLink MOXy as the JAXB provider you need to put a jaxb.properties in one of the packages for your domain objects, that is passed in to bootstrap the JAXBContext. For example if your JAXBContext will be based on the following 2 classes: example.foo.Foo example.bar.Bar example.foo.Foo package

@Size annotation not recognized (JPA)

徘徊边缘 提交于 2020-01-04 04:02:46
问题 I want to validate the length of a String before trying to insert/update the entity to the Database. @Size(min = 1, max = 45) @Column(name = "name", nullable = false, length = 45) private String name; My problem is the @Size annotation is not being recognized using NetBeans 7.3, JDK 1.6, EclipseLink (JPA 2.0). Is there an alternative to this ? 回答1: Try to include <dependency> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> <version>1.1.0.Final</version> <

@Size annotation not recognized (JPA)

匆匆过客 提交于 2020-01-04 04:02:41
问题 I want to validate the length of a String before trying to insert/update the entity to the Database. @Size(min = 1, max = 45) @Column(name = "name", nullable = false, length = 45) private String name; My problem is the @Size annotation is not being recognized using NetBeans 7.3, JDK 1.6, EclipseLink (JPA 2.0). Is there an alternative to this ? 回答1: Try to include <dependency> <groupId>javax.validation</groupId> <artifactId>validation-api</artifactId> <version>1.1.0.Final</version> <

EclipseLink JPA 2.1 User supplied connection

柔情痞子 提交于 2020-01-04 02:57:05
问题 I would like to use EclipseLink as my JPA engine. We are using a subclass of java.sql.Connection and I would like to know if I can force EclipseLink to use my connection. I would like to set the connection object programmatically. Something like MyConnection conn = new MyConnection(JDBC_URL, USR, PWD); EntityManagerFactory factory = Persistence.createEntityManagerFactory(conn); 回答1: You can set a custom connection programatically using the following code: Map properties = new HashMap(); //

EclipseLink JPA 2.1 User supplied connection

你。 提交于 2020-01-04 02:57:03
问题 I would like to use EclipseLink as my JPA engine. We are using a subclass of java.sql.Connection and I would like to know if I can force EclipseLink to use my connection. I would like to set the connection object programmatically. Something like MyConnection conn = new MyConnection(JDBC_URL, USR, PWD); EntityManagerFactory factory = Persistence.createEntityManagerFactory(conn); 回答1: You can set a custom connection programatically using the following code: Map properties = new HashMap(); //

Internal Exception: java.sql.SQLException: Invalid state, the Connection object is closed

冷暖自知 提交于 2020-01-04 02:56:11
问题 I have a JSF application that uses Eclipse Persistence Services - 2.1.1.v20100817-r8050, and I sometimes get the following error: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.1.v20100817-r8050): org.eclipse.persistence.exceptions.DatabaseException Internal Exception: java.sql.SQLException: Invalid state, the Connection object is closed. Error Code: 0 Call: SELECT XXXXX FROM XXXXX bind => [/Home/Footer/] Query: ReadAllQuery(name="WWW.find" referenceClass=WWW sql="SELECT

Eclipselink Entity is not recognized

删除回忆录丶 提交于 2020-01-04 02:11:08
问题 I have Versions which may rely on other Version. The dependent Versions are stored in the List dependsOn . Because I need to be able to determine, in what other Versions a specific Version is used I have the List usedIn which is the inverse of dependsOn. My Problem is as soon as I add methods to add/remove a single Version from dependsOn EclipseLink does not recognize my class Version as entity anymore. My Version class: @Entity @Table( name = "tbl_version" ) @NamedQueries( /*...*/ ) public

With Eclipselink Moxy How do I map xml content to a name different to value?

岁酱吖の 提交于 2020-01-03 19:37:09
问题 In my Xml I have: <alias-list> <alias sort-name="Afghan">Afghany</alias> </alias-list> The json is output as "aliases" [ { "sort-name" : "Afghan", value : "Afghany" } ] but I want it to be: "aliases" [ { "sort-name" : "Afghan", name : "Afghany" } ] So I know how to use oxml.xml to rename an attribute but in this case there is no attribute so unsure how to proceed. 回答1: There is a property you can set to override the default "value" for MOXy's JSON marshalling. This property is set per context

javax.validation.ValidationException: HV000041: Call to TraversableResolver.isReachable() threw an exception

北战南征 提交于 2020-01-03 14:18:17
问题 I got below error javax.validation.ValidationException: HV000041: Call to TraversableResolver.isReachable() threw an exception. at org.hibernate.validator.internal.engine.ValidatorImpl.isReachable(ValidatorImpl.java:1405) at org.hibernate.validator.internal.engine.ValidatorImpl.isValidationRequired(ValidatorImpl.java:1381) at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:542) at org.hibernate.validator.internal.engine.ValidatorImpl