My EntityManager is using a persistence unit that uses a data source provided by our Websphere configuration. The DS configuration includes an environment specific DB to use.
The EM successfully uses this schema, but I can't figure out a way to log or display the schema being used. I was thing something like em.getCurrentSchema would b...
Hi,
I'm trying to learn JPA. I created a simple entity class. This entity has 3 columns: ID, NAME, NUMBER_A. It's working fine: I can persist, update and delete without problems.
What I'm trying to do is to create a calculated/computed column. I want to retrieve NUMBER_A, use it to calculate a new value and set the calculated column (l...
Hello friends,
I am creating web application using zkoss 5.0.4, Spring 3.0.3, Hibernate 3 and JpA 1.0 with JBOSS 5.1 GA(with jdk support).
project compiles fine with JBOSS. But it seems that persitence is not applying for some reason.
When I run an application in console it gives following
10:07:35,265 WARN [QuerySplitter] no persis...
I'm developing a JEE application (JSF + Richfaces + Oracle 10g), and i wanted to use JPA.
But in the end, i didn't see any advantages of using it, because it's going to complexify my code.
I found that calling my procedures (stored procedures in my orale DB) is better than using JPA (because i can, for example, change some lines in tho...
I'm tired of navigating Oracle's joke of a website! Where do we go for JPA docs?
...
Hello,
My project uses Spring, JPA, and Hibernate, so that all EntityManager's are injected by Spring.
I need to access persistent classes' meta data such as column lengths and optionality. The only way I know to obtain this information is through Hibernate's Configuration.getClassMapping(String className). In a pure Hibernate project ...
I've here a database with a PERSON - ADDRESS - ADDRESS_TYPE relationship maintained by a triple join table PERSON_ADDRESS. The PERSON-ADDRESS relationship is effectively one-to-many.
PERSON
ID FIRSTNAME LASTNAME
-- --------- --------
1 John Doe
2 Jane Doe
ADDRESS
ID STREET CITY
-- -------------------- ---...
Hi, I have an the following scenario:
// several classes that implement different interfaces
class A implements X,Y {}
class B implements Y,Z {}
class C implements X,Z {}
// other classes that contain collections of one of the interfaces(different objects)
class G {
Collection<X> mayContainAC;
}
class H {
Collection<Y> mayContainA...
The following NamedQuery is giving a parsing error in Eclispelink . please help
@NamedQuery(name = "OaaFlexrolesUnitT.findFlexRolesAvailableUsers",
query = "select c.netId,a.emplname from IsiEdbBasT a,NyuEdbEmpT b,OaaUserRolesT c where a.emplid=b.emplid and a.emplstat <> 'X' and a.orgid = ' ' and a.qtrno = 0 and a.orgid =...
I was reading an article in which the author had implemented an Entity class like this:
@Entity
public class Product {
@OneToMany
private List<Part> parts; // note the missing "= new ArrayList<Part>();"
public Product() {
}
// getters and setters
}
I always used to instantiate collection fields, in this case parts, either inl...
If i use ex.merge(obj), now if in object obj i set the primary key to a value which is not present in database, will it create a new record or will it throw an exception?
for example
if obj with pk val = 19 doesnot exist in database,and i set
obj.setPk(20);
obj.setName("nm");
em.merge(obj) // will this throw an exception or create a ...
This is my code, which I can't even compile:
/**
* Find a project that has NO employee assigned yet.
*/
public Project findEmptyProject() {
// getting criteria builder
CriteriaBuilder cb = this.em.getCriteriaBuilder();
// gathering meta information about left-joined entity
Metamodel m = this.em.getMetamodel();
EntityType<Emp...
My Java application is using JPA for object persistence. The business domain is very simple (just three classes are persistent, with 3-5 properties in each). Queries are simple as well. The question is which approach I should use: JPQL or Criteria API?
...
Hi all,
My google-fu is failing me in this. I'm doing a small database app which reads some data from a file along with some meta data that I currently store in a Map in my entity. I'm getting fed up with it always being displayed in a random order.
So can I use a LinkedHashMap or @OrderColumn with Maps somehow to preserve insertion or...
I am using a JPA distinct projection to get some data:
select distinct o.f1, o.f2, o.f3 from SomeEntity o where ...
This works fine with setFirstResult and setMaxResults to page data.
However I need to count the total number of rows without fetching all of them. I have tried:
select count(distinct o.f1, o.f2, o.f3) from SomeEntity o...
This is the class I'm trying to test:
@Stateless
public class Finder {
@PersistenceContext(unitName = "abc")
EntityManager em;
public String read(int i) {
return this.em.find(Employee.class, i).getName();
}
}
This is the unit test:
public class FinderTest {
@Test public void testReadingWorks() {
Finder f = new Finde...
I used ImprovedNamingStrategy in hibernate, to mapping Java field name to MySQL column name.
ex) birthDate field -> birth_date column, AccountRole class -> account_role table
I'm doing test migrating hibernate code to eclipselink code.
What is the equivalent in EclipseLink to hibernamte's ImprovedNamingStrategy ?
...
This is my stateless bean:
@Stateless
public class Finder {
@PersistenceContext(unitName = "production")
EntityManager em;
[...]
}
It explicitly defines that the name of persistence unit is production. This unit is configured in persistence.xml, and everything is fine. When I'm unit testing this class I have to use another persi...
I'm trying to figure out how to configure my project such that JPA will timeout and throw an exception after a configured amount of time. There are two situations where I would like this to happen:
When JPA is unable to even connect to the database
When a JPA query takes longer than the timeout threshold to return a result set
I'm no...
The requirement is that the user can write an article, therefore I choose type Text for the content field inside mysql database. How can I convert Java String into MySQL Text
Here you go Jim Tough
@Entity
public class Article implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(stra...