[JBoss Seam] - pagination problem, advice needed
by liudan2005
I've been trying to solve this problem for ages but still couldn't find a good solution. I have an entity which looks like this:
| class Person{
| String name;
| int age;
| List<Review> reviews;
| List<Call> calls;
| }
|
in my jsf page, I have:
| <h:outputText value="person.name" />
| <h:outputText value="person.age" />
| <h:dataTable value="person.reviews" var="review" rows="5">
| ...
| </h:dataTable>
|
| <h:dataTable value="person.calls" var="call" rows="5">
| ...
| </h:dataTable>
|
|
both reviews and calls need to have their own page control because there can be more than 1000 rows.
The ideal way to do this is to have a scroller component that is similar to t:dataScroller, but only load the required data rows from database each time when change the page. However, this component doesn't exist in this world. Without such a component, I would have to write customised HSqls for each entity and write my own scroller component. Since I have a lot of entities that are similar to this one, it's so time consuming to do it this way. Can someone give any advice what would be the easiest way to solve this problem?
Also, I have another question, is there anyway to limit the number of returning rows when define @OneToMany relationship. e.g. @OneToMany(fetch=FetchType.EAGER, maxNumberOfRows=10) ?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4005996#4005996
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4005996
19 years, 3 months
[JBoss Seam] - PersistenceException during testNG unit test
by asookazian
Based on the following persistence.xml file (which is located in my Eclipse project's resources/META-INF folder):
<?xml version="1.0" encoding="UTF-8"?>
<persistence-unit name="RSDB"> org.hibernate.ejb.HibernatePersistence
<jta-data-source>java:jdbc/RespaJbossDS</jta-data-source>
<!-- These are the default for JBoss EJB3, but not for HEM: -->
</persistence-unit>
I get the following excpetion in the testNG plugin window in Eclipse when I run my testNG test suite:
javax.persistence.PersistenceException: No Persistence provider for EntityManager named RSDB
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:41)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:27)
at example1.DashboardActionTest.init(DashboardActionTest.java:53).......
I am trying to manually inject the EntityManager instance into the Action class that is being tested b/c otherwise I get nullpointerexception.
Here's the Test class code:
package example1;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import org.testng.annotations.Configuration;
import org.testng.annotations.Test;
import com.h123.loantrack.DashboardAction;
import com.h123.loantrack.User;
public class DashboardActionTest
{
@Test
public void testDashboardAction()
{
EntityManager em = getEntityManagerFactory().createEntityManager();
//em.getTransaction().begin();
User user = new User();
user.setUserID(10471);
DashboardAction action = new DashboardAction();
action.setUser(user);
action.setRSDB(em);
assert "main".equals(action.findAppLoanRecords());
assert "main".equals(action.findPQLoanRecords());
assert "main".equals(action.findQRWLoanRecords());
assert "main".equals(action.findWFLoanRecords());
//em.getTransaction().commit();
//em.close();
}
private EntityManagerFactory emf;
public EntityManagerFactory getEntityManagerFactory()
{
return emf;
}
@Configuration(beforeTestClass=true)
public void init()
{
emf = Persistence.createEntityManagerFactory("RSDB");
}
@Configuration(afterTestClass=true)
public void destroy()
{
emf.close();
}
}
Anybody know how to fix this?
I found the following info from http://www.hibernate.org/hib_docs/entitymanager/reference/en/html/configu...:
When Persistence.createEntityManagerFactory() is called, the persistence implementation will search your classpath for any META-INF/persistence.xml files using the ClassLoader.getResource("META-INF/persistence.xml") method. Actually the Persistence class will look at all the Persistence Providers available in the classpath and ask each of them if they are responsible for the creation of the entity manager factory manager1. Each provider, from this list of resources, it will try to find an entity manager that matches the name you specify in the command line with what is specified in the persistence.xml file (of course the provider element must match the current persistent provider). If no persistence.xml with the correct name are found or if the expected persistence provider is not found, a PersistenceException is raised.
So is my persistence.xml not in the classpath? Running test suite inside Eclipse without JBoss running.
thanks.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4005982#4005982
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4005982
19 years, 3 months