This content has been marked as final.
Show 4 replies
-
1. Re: Using EntityManager in a SFSB method with a4j:Support action?
pgmjsd Apr 20, 2009 9:44 PM (in response to oberiko.oberiko.gmail.com)Are you sure you're using the same SFSB every time? When does the conversation begin and end?
-
2. Re: Using EntityManager in a SFSB method with a4j:Support action?
oberiko.oberiko.gmail.com Apr 20, 2009 9:48 PM (in response to oberiko.oberiko.gmail.com)Since I have the SFSB in the SESSION scope, do I need to indicate a beginning and end? I can refactor it a conversation instead if that helps.
-
3. Re: Using EntityManager in a SFSB method with a4j:Support action?
oberiko.oberiko.gmail.com Apr 20, 2009 10:26 PM (in response to oberiko.oberiko.gmail.com)I've put the SFSB into the CONVERSATION scope, but I still get the same problem.
** SFSB **
@Stateful
@Name("directory")
@Scope(ScopeType.CONVERSATION)
public class DirectoryBean implements Directory {
@PersistenceContext(type = PersistenceContextType.EXTENDED)
protected EntityManager entityManager;
@RequestParameter protected Long directoryId;
.
.
.
//This method gets called from pages.xml on entering the page.
public void load() {
if (directoryId != null && (directory == null || directory.getId() != directoryId)){
start();
//Do loading stuff
}
}
@Begin
public void start() {
log.info("Starting the conversation");
}
public void findPeople() {
if (personName == null || personName.length() == 0 || cityName == null
|| cityName.length() == 0)
return;
if (entityManager == null)
log.info("EntityManager is null?!"); //This is what's happening
else {
List <Person> matchingPeople = (List<Person>) entityManager.createQuery(
"from Person p where name = :name and city = :city")
.setParameter("name", personName)
.setParameter("city", cityName)
;
}
@End
public void saveDirectory(){
//Save stuff
}
@End
public void cancel() {}
} -
4. Re: Using EntityManager in a SFSB method with a4j:Support action?
oberiko.oberiko.gmail.com Apr 20, 2009 11:51 PM (in response to oberiko.oberiko.gmail.com)Turns out I'm just blind. I was missing a .getResultList() at the end of my query.
After doing the conversation change it now usually works; seems a little random though. (If it doesn't I restart JBoss, try again, and it usually does).