jpa-2.0

getting error Invalid Oracle URL specified: OracleDataSource.makeURL

大城市里の小女人 提交于 2019-12-11 01:55:01
问题 I am getting error when I try to run my application on Server. I am suing eclipse and glass fish server 4. I made a glassfish-resources.xml file and put it in the WEB-INF directory. When I try to run on server. I get the following exception Internal Exception: java.sql.SQLException: Error in allocating a connection. Cause: Connection could not be allocated because: Invalid Oracle URL specified: OracleDataSource.makeURL Error Code: 0 at org.eclipse.persistence.exceptions.DatabaseException

JPA CDI Injecting DAO into an Entity

我的梦境 提交于 2019-12-11 01:04:36
问题 I'm new to JPA and CDI and I'm trying to create an enterprise application using these frameworks. I get how I can inject into beans and keep everything tidy and stateless. I also get that JPA loads relations etc. for me so that I don't have to worry about it anymore. I still use my DAO's for specific find methods and ofcourse to create new entities. I understand that I don't want to be injecting stuff into my entities since they're managed by JPA and I need to use the new keyword to create a

Can JPA 2.0 be used without JavaEE 6?

℡╲_俬逩灬. 提交于 2019-12-10 23:13:48
问题 I am using OpenJPA 2.1 (which implements JPA 2.0 ) for a command line utility. I am using classes that are new for JPA 2.0 . My compile target is Java SE 1.6 OpenJPA 2.1 comes with all JPA 2.0 javax.persistence.* interfaces/implementations. Can I claim that my utility has no dependence on JavaEE 6 ? My understanding is that JavaEE 6 is a collection of standards. So it is no different in that respect from any other random set of standards. Hence JavaEE 6 depends on JPA 2.0 , but JPA 2.0 does

Spring data JPA using Entity Type expression

谁都会走 提交于 2019-12-10 22:28:41
问题 I would like to use the JPA 2.0 Type expression in a spring data JPA repository @Query but it give me a validation error Validation failed for query for method public abstract java.util.List my.org.FooRepository.findAllByRoomCode()! . Here is my entities definition : inherited : @Entity(name = "Location") @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) public abstract class LocationEntity { @Column(name = "CODE") protected String code; @OneToMany(mappedBy = "location") protected List

How to make a @ManyToOne field mandatory in JPA2?

孤街浪徒 提交于 2019-12-10 21:14:43
问题 I am designing the persistence repository for an app. I am new to Hibernate+JPA2 and I am having trouble creating more complex relationships in this case a Foreign mandatory key . An example ( just wrote on notepad, so it's not exactly this. ) I have a Top Class called Person which can hold several Posts (another class). If I map my top class like this @Entity @Table(name="tb_people") public class Person{ @Id @GeneratedValue public long id; @OneToMany(mappedBy="person") List<Post> listOfPosts

JPA one-to-many unidirectional relationship using a join table

﹥>﹥吖頭↗ 提交于 2019-12-10 21:13:41
问题 I would like to evaluate JPA on an existing project. The database model and the java classes exists and are currently mapped via self generated code. The database model and the java classes do not fit ideally together - but the custom mapping works well. Nevertheless the usage of JPA in general seems worth a try. As you see I am new to JPA and have to do the work with xml configuration. Currently I am working on a one-to-many unidirectional relationship using a join table (please do not

jpa2 CriteriaBuilder order by “ORDER BY expressions must appear in select list”

心已入冬 提交于 2019-12-10 21:08:19
问题 I'm writing a query with CriteriaBuilder , but it has not been possible to add the order by clause, because an error it's thrown with the message ORDER BY expressions must appear in select list this are my entities. public class A{ Integer aId; @ManyToOne @JoinColumn(name = "bId", nullable = false) B classB; //setter and getter. } public class B{ Integer bId; String name; //setter and getter. } my query look like this. CriteriaBuilder cb = super.getEntityManager().getCriteriaBuilder();

@EmbeddedId with autogenerated id using @GenerateValue, this mix doesn't works as needed

假如想象 提交于 2019-12-10 19:54:16
问题 I am trying to work with @EmbeddedId, this is my code as follows, create table TBL_EMPLOYEE_002( ID integer generated always as identity (start with 100,increment by 10), COUNTRY varchar(50), NAME varchar(50), constraint PK_EMP_00240 primary key(ID,COUNTRY) ) The Embedded class as follows, @Embeddable public class EmployeeIdTwo implements Serializable{ public EmployeeIdTwo(){} public EmployeeIdTwo(String country){ this.empCountry = country; } @GeneratedValue(strategy=GenerationType.IDENTITY)

How to specify multiple conditions on left join using JPA Criteria API?

放肆的年华 提交于 2019-12-10 19:29:40
问题 I'd like to convert the following SQL query: select * from region_tree country left outer join region_tree region on country.REG_CODE_PAR=region.REG_CODE and region.LFT < country.LFT and region.RGT > country.RGT and region.REG_CODE_PAR = 'ALL' and COUNTRY.STATUS_CODE = 'A' and REGION.STATUS_CODE = 'A into JPA Crtieria based query. I created an entity to represent the self join: @Entity @Table(name = "REGION_TREE") public class RegionTree implements Serializable { ... some other attributes

sun.reflect.annotation.TypeNotPresentExceptionProxy exception after adding EntityListeners

a 夏天 提交于 2019-12-10 18:48:19
问题 When an EntityListeners was added to the application using the @EntityListeners(value = {MyEventListener.class}) , got the following crash. It looks an issue with reflection. The application has a custom annotation defined for the same entity. Note that this crash only happens after adding the EntityListeners. If the custom annotation is commented the application will still crash. The weird thing is that the same code will work fine when run through the Netbeans debugger. The getAnnotation()