I am using Spring + EclipseLink 2 to manage entity on a Derby database. Select object from db works fine but when I try to persist one, nothing happens. Program executes correctly and no exception are thrown. I probably did something wrong, as I'm not familiar with Spring, thanks for your comments and suggestions :)
The ServerDaoDb meth...
Hello All!
i have trouble with JPQL statement, i created NameQuery followed:
@NamedQuery(name = "Cart.findExistCart", query = "SELECT c FROM Cart c WHERE c.cartPK.userid = :userid AND c.cartPK.itemid = :itemid "),
in stateless bean i create one method to active this query followed:
public Cart getUserItemCart(int userid,int itemi...
Hello there, i'm trying to convert a 'TableController'-Class we used (without ORM) to generate dynamic SQL (actually the order column and direction is appended to the SQL).
Think of this 'TableController' as a class that have a function to return a list of Entities of a given class (known at runtime), in a given order (String column/pro...
What value should I place into <jta-data-source> of my persistence.xml?
In glassfish admin panel I created a datasource name "abcDS". In my jndi.properties (inside src/test/resources) I defined it like this:
[...]
abcDS=new://Resource?type=DataSource
abcDS.JdbcDriver=org.hsqldb.jdbcDriver
abcDS.JdbcUrl=jdbc:hsqldb:mem:testdb
abcDS.JtaM...
This is my persistence.xml:
<persistence>
<persistence-unit name="MyUnit">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/abcDS</jta-data-source>
</persistence-unit>
</persistence>
This is jndi.properties file from src/test/resources which is supposed to create a datasource during testing...
here is my code snippet:
@Stateless
public class mySLSB {
@PersistenceContext(unitName = "db")
private EntityManager myEntityManager;
public void crud(MyEntity myEntity) throws MyException {
myEntityManager.merge(myEntity);
}
}
However this merge can cause a ConstraintViolationException, which does not throw MyException (which i...
I would like to make use @IndexColumn to set seq number of some data the user enters. I am using Spring 2.5.6, JBoss 5.1 (JPA 1.0).
For my parent class
@Entity
@Table(name="material")
public class Material implements Serializable {
.
.
/**
* List of material attributes associated with the given material
*/
@OneToMany...
Hey guys, I have the following query and for the life of me I can't seem to translate it into JPQL. The working SQL is:
select * from TB_PRINT_DETAIL y inner join
(select JOB_ID,max(COPY_NUM) MAX_COPY_NUM from TB_PRINT_DETAIL group by JOB_ID ) x
on y.JOB_ID = x.JOB_ID and y.COPY_NUM = x.MAX_COPY_NUM
My feeble attempt at translati...
I'm trying to use a UUID for a primary key using JPA 2 (EclipseLink). I'm using PostgreSQL as the database. I have my entity declared as follows: I have an Employee table with its PK set as a UUID. I have a JPA Entity mapping to the employee table, which looks like this:
@Entity
public class Employee {
@Id
private String id;
...
I have query in mysql like
SELECT COUNT(DISTINCT MOBILE) FROM TBLM_CUSTOMER WHERE MOBILE NOT REGEXP '^00*0$' AND LENGTH(MOBILE) >= 10;
I am using EJB 3.0 and I want to make same query using NamedQuery, same thing is possible using createQuery , but i want to use NamedQuery.
Is it possible to use regular expression using NamedQuery in...
This question is in relation to another question I have asked, but what are the reasons as to why you would use openSession() over getCurrentSession()? I know you would use openSession() so that you could self-manage the closing and flushing of the session, however, why would you want to do this manually?
I have used openSession() when...
public class Group{
@ManyToMany(fetch=FetchType.EAGER, cascade=CascadeType.ALL, mappedBy="groups")
public Set<User> getUsers() {
if(users == null)
return new HashSet<User>();
else
return users;
}
public void setUsers(Set<User> users) {
this.users = users;
}
}
public class User{
public void setGroups(Set<Group> groups)...
Hi,
I have a simple app with User, Bid, and Auction, the relationships are clear I hope.
Now I want to implement getWinningAuctionsOfuser( User u ), which would return the auctions which the given user is currently winning.
I know how I would do this in SQL, but I don't have much experience with JP-QL.
What's the best approach?
Curr...