shabeesh / generic-dao Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/generic-dao
Automatically exported from code.google.com/p/generic-dao
Given some Java code like:
Criteria criteria = Criteria.forClass(Projet.class);
criteria.add(Restrictions.eq("campagne.id", idCampagne));
DAO.findByCriteria(criteria);
Using EclipseLink JPA provider (I updated the pom.xml), I get this error:
java.lang.IllegalArgumentException: An exception occurred while creating a
query in EntityManager:
Exception Description: Syntax error parsing the query [select this from Projet
as this where this.campagne.id=?], line 0, column -1: unexpected end of query.
Internal Exception: NoViableAltException(-1!=[792:1:
comparisonExpressionRightOperand returns [Object node] : (n=
arithmeticExpression | n= nonArithmeticScalarExpression | n= anyOrAllExpression
);])
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1373)
at com.szczytowski.genericdao.criteria.Criteria.prepareQuery(Criteria.java:333)
at com.szczytowski.genericdao.criteria.Criteria.list(Criteria.java:236)
at com.szczytowski.genericdao.impl.GenericDao.findByCriteria(GenericDao.java:319)
[...]
It looks like "select this from Projet as this where this.campagne.id=?" is not
a valid JPQL query.
AFAIK numbered parameters must be specified with an index, e.g.:
"select this from Projet as this where this.campagne.id=?1"
Whereas Hibernate HQL doesn't need this index, that's why included tests for
criteria succeed.
Original issue reported on code.google.com by [email protected]
on 27 Jan 2011 at 11:24
I have:
My DAO Interface:
{{{
public interface UserDao extends IDao<User, Long> {
void persist(User user);
User findByLogin(String login);
}
}}}
My DAO Implementation:
{{{
@Repository
@Transactional(readOnly = true)
public class UserDaoImpl extends GenericDao<User, Long> implements UserDao {
public UserDaoImpl() {
}
@SuppressWarnings("unchecked")
public User findByLogin(String login) {
List<User> list = findByCriteria(Criteria.forClass(User.class).add(
Restrictions.eq("login", login)));
if (list == null || list.size() != 1) {
return null;
}
return list.get(0);
}
}
}}}
But when i need save in the controller with: userDao.save(user) nothings
happen in the database.
I have using Spring + Spirng MVC + JPA + Hibernate
I need help, thanks you.
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 11 Sep 2009 at 5:10
EntityManager injected via default persistence unit:
@PersistenceContext
public final void setEntityManager(EntityManager entityManager) {
this.entityManager = entityManager;
}
Howto deal with several persistence units?
Original issue reported on code.google.com by [email protected]
on 21 Aug 2010 at 8:44
I have noticed that findByExample method only take care of annotated fields
but has no effect if the annotations are in getter methods.
Original issue reported on code.google.com by [email protected]
on 13 Mar 2008 at 12:46
Hi EntityManager in GenericDao is not injected. This could be, because
GenericDao is not a EJB class managed. How can inject automatically ?
Thanks.
Edson.
Original issue reported on code.google.com by [email protected]
on 3 Dec 2008 at 2:22
What steps will reproduce the problem?
1. i download the code (svn)
2. run mvn install
maybe a dependence in the pom file ?
Original issue reported on code.google.com by [email protected]
on 28 Aug 2009 at 5:37
-When running VATRManagerTest.findAll() as a JUnit test, I'm getting a
ClassCastException:
Caused by: java.lang.ClassCastException: java.lang.Class cannot be cast to
java.lang.reflect.ParameterizedType
at com.szczytowski.genericdao.impl.GenericDao.<init>(GenericDao.java:53)
at be.fodfin.proto.genericdao.VATRManagerImpl.<init>(VATRManagerImpl.java:11)
-What version of the product are you using? On what operating system?
I'm using genericdao v1.0 on WindowsXP
-Please provide any additional information below.
Eclipse project has been attached.
Original issue reported on code.google.com by [email protected]
on 17 May 2010 at 10:29
Attachments:
What steps will reproduce the problem?
1. Create a method that make a query via findByExample
2. Execute the methode
3. The list return contains the whole table
With an example containing my primary key I expect only one result but I
alway have the whole table.
I'm using Generic DAO 1.0
Here is an example of my way of using it.
UserObject implements IEntity<Long>
UserObjectManager extends IDao<UserObject, Long>
UserObjectManagerImpl extends GenericDao<UserObject, Long> implements
UserObjectManager
UserObjet userObject = new UserObject();
userObject.setId(new Long(0));
List<UserObject> myList = userObjectManager.findByExample(userObject)
System.out.println("size = "+myList.size());
-> I got 1321;
How do I have to use this method, findByExemple.
if i performe the same query with a criteria it works
findByCriteria(Criteria.forClass(UserObject.class).add(Restrictions.eq("login",
login)))
Please, help
Thanks you
Original issue reported on code.google.com by [email protected]
on 6 Nov 2009 at 12:21
Hi Guys,
I wanted to post a query, could not find a better place to place this. :)
Your framework will force the users to implement EntityImpl for all the
entities.
Why is it required? The other similar frameworks like the ones with hibernate
generic support do not have constraints like this. I would no like to alter my
existing entities just to use a new framework. Can it not be done without this
constraint?
Cheers
Sushant
[email protected]
Original issue reported on code.google.com by [email protected]
on 14 Jun 2011 at 9:48
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.