-
1. Re: rowCount and EntityManager
dhcinc Nov 29, 2009 12:58 PM (in response to schnulla)In your query, you are asking for a count of the number of users. As such, you will always get one row back from the select.
Perhaps you meant to use
SELECT user from User user
? -
2. Re: rowCount and EntityManager
schnulla Nov 29, 2009 4:19 PM (in response to schnulla)You are right it must be
SELECT user from User
. Thank you!I wonder how I could use COUNT() and outject that value
to my h:outputText? And how-to update this value because
at the moment DataModel is only populated on the first
page visit.Thanks for any hints :)
-
3. Re: rowCount and EntityManager
schnulla Nov 29, 2009 4:22 PM (in response to schnulla)
You are right it must beSELECT user from User
. Thank you!uups I meant
SELECT name from User
-
4. Re: rowCount and EntityManager
meetoblivion Nov 29, 2009 5:20 PM (in response to schnulla)well if you want to outject the count, you could do something like this:
private BigDecimal userListSize;
@Factory("userListSize")
public void populateUserListSize() {
userListSize = entityManager.createQuery("SELECT COUNT(*) FROM User").getSingleResult();
}or you could use the existing userList
private BigDecimal userListSize;
@Factory("userListSize")
public void populateUserListSize() {
userListSize = userList.size();
} -
5. Re: rowCount and EntityManager
schnulla Nov 29, 2009 7:30 PM (in response to schnulla)Thanks the first works fine and this way I get
rid of the @DataModel and .rowCount stuff :)I guess COUNT() is also more performant than
SELECT user FROM User?The only thing I have to solve now is to
update userListSize on every page visit.
What is the standard practice to do this?Thanks for the help :)