[JBoss Seam] - Re: EntityHome.persist fails with @GeneratedValue
by asookazian
JBOSS4.2.1.GA
SEAM2.0.0.GA
Same problem here (but w/o EntityHome design pattern). I am seeing the following in the server.log before the exception. Occurs with or w/o using the TransactionalSeamPhaseListener in faces-config.xml. I am using SMPC with flushMode=MANUAL. This could be a programmer's error but I don't know why it states "mark transaction for rollback" when the persist() method is called on the EntityManager. There is no SQLException in the server.log.
SFSB:
| for (int i = 0; i < 3; i++) {
| TblSecurityAuditNote note = getTblSecurityAuditNote(currentRowNum, i);
| if (note != null) {
| log.info("myNotes["+currentRowNum+"]["+i+"]: noteId = " + note.getNoteId() + " noteText = " + note.getNoteText());
| emICOMS.persist(note);
| }
| }
|
| emICOMS.flush();
stack trace:
2007-12-20 15:16:59,074 INFO [com.cox.beans.interceptor.LoggerInterceptor] *** Entering method: submit
| 2007-12-20 15:16:59,074 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.interpolator
| 2007-12-20 15:16:59,074 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.interpolator
| 2007-12-20 15:16:59,074 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.interpolator
| 2007-12-20 15:16:59,074 INFO [com.cox.beans.session.SecurityAuditAction] myNotes[0][1]: noteId = null noteText = asdf
| 2007-12-20 15:16:59,074 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] executing identity-insert immediately
| 2007-12-20 15:16:59,074 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
| 2007-12-20 15:16:59,074 DEBUG [org.hibernate.jdbc.ConnectionManager] opening JDBC connection
| 2007-12-20 15:16:59,074 DEBUG [org.hibernate.SQL] insert into boIcomsSecurityAudit.dbo.tblSecurityAuditNote (TimeStamp, NoteText, SITE_ID, EMPLOYEE_NUMBER, NoteType) values (?, ?, ?, ?, ?)
| 2007-12-20 15:16:59,074 DEBUG [org.hibernate.id.IdentifierGeneratorFactory] Natively generated identity: 262
| 2007-12-20 15:16:59,074 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
| 2007-12-20 15:16:59,074 DEBUG [org.hibernate.jdbc.ConnectionManager] aggressively releasing JDBC connection
| 2007-12-20 15:16:59,074 DEBUG [org.hibernate.jdbc.ConnectionManager] releasing JDBC connection [ (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)]
| 2007-12-20 15:16:59,074 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.interpolator
| 2007-12-20 15:16:59,074 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.interpolator
| 2007-12-20 15:16:59,074 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.interpolator
| 2007-12-20 15:16:59,074 INFO [com.cox.beans.session.SecurityAuditAction] myNotes[0][2]: noteId = 261 noteText = sdf
| 2007-12-20 15:16:59,074 DEBUG [org.hibernate.ejb.AbstractEntityManagerImpl] mark transaction for rollback
| 2007-12-20 15:16:59,074 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.interpolator
| 2007-12-20 15:16:59,074 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.interpolator
| 2007-12-20 15:16:59,074 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.interpolator
| 2007-12-20 15:16:59,074 DEBUG [com.cox.beans.interceptor.ProfilingInterceptor] *** Method public void com.cox.beans.session.SecurityAuditAction.submit() executed in 0ms ***
| 2007-12-20 15:16:59,074 DEBUG [org.jboss.seam.util.Naming] JNDI InitialContext properties:{java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory, java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces}
| 2007-12-20 15:16:59,074 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.interpolator
| 2007-12-20 15:16:59,074 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.interpolator
| 2007-12-20 15:16:59,074 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.interpolator
| 2007-12-20 15:16:59,074 INFO [com.cox.beans.session.SecurityAuditAction] in preDestroy
| 2007-12-20 15:16:59,074 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
| 2007-12-20 15:16:59,074 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
| 2007-12-20 15:16:59,074 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
| 2007-12-20 15:16:59,074 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
| 2007-12-20 15:16:59,074 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
| 2007-12-20 15:16:59,074 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
| 2007-12-20 15:16:59,074 DEBUG [org.jboss.seam.core.Events] Processing event:org.jboss.seam.preRemoveVariable.securityAuditAction
| 2007-12-20 15:16:59,074 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
| 2007-12-20 15:16:59,074 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
| 2007-12-20 15:16:59,074 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
| 2007-12-20 15:16:59,074 DEBUG [org.jboss.seam.Component] instantiating Seam component: org.jboss.seam.core.events
| 2007-12-20 15:16:59,074 DEBUG [org.jboss.seam.Component] initializing new instance of: org.jboss.seam.core.events
| 2007-12-20 15:16:59,074 DEBUG [org.jboss.seam.Component] done initializing: org.jboss.seam.core.events
| 2007-12-20 15:16:59,074 DEBUG [org.jboss.seam.core.Events] Processing event:org.jboss.seam.postRemoveVariable.securityAuditAction
| 2007-12-20 15:16:59,074 DEBUG [org.jboss.seam.ejb.RemoveInterceptor] Stateful component was removed: securityAuditAction
| 2007-12-20 15:16:59,090 ERROR [STDERR] Dec 20, 2007 3:16:59 PM javax.faces.event.MethodExpressionActionListener processAction
| SEVERE: Received 'javax.ejb.EJBTransactionRolledbackException' when invoking action listener '#{securityAuditAction.submit}' for component 'submitEmployee'
| 2007-12-20 15:16:59,090 ERROR [STDERR] Dec 20, 2007 3:16:59 PM javax.faces.event.MethodExpressionActionListener processAction
| SEVERE: javax.ejb.EJBTransactionRolledbackException: org.hibernate.PersistentObjectException: detached entity passed to persist: com.cox.beans.entity.TblSecurityAuditNote
| at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:87)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4114834#4114834
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4114834
18 years, 4 months
[JBoss Seam] - Parameters and @Factory
by amorfis
Hi,
This is something I made based on "blog" example from seam 2.0.0GA (the one I use).
I have such component in my app:
@Name("search")
| public class SearchBean {
|
| private String province;
|
| private String category;
|
| @Factory("searchResults")
| public List<Article> search() throws InkaSearchException {
| //get articles based on province and category.
| }
|
| public String getProvince() {
| return province;
| }
|
| public void setProvince(String province) {
| this.province = province;
| }
|
| public String getCategory() {
| return category;
| }
|
| public void setCategory(String category) {
| this.category = category;
| }
|
| }
search.jsp page looks like this:
<h:form>
| <h:selectOneMenu value="#{search.category}">
| <s:selectItems var="category" value="#{categories}"/>
| </h:selectOneMenu>
| <h:selectOneMenu value="#{search.province}">
| <s:selectItems var="province" value="#{provinces}"/>
| </h:selectOneMenu>
| <h:commandButton value="Szukaj" action="search"/>
| </h:form>
| <h:dataTable var="art" value="#{searchResults}">
| <!-- display search results -->
| </h:dataTable>
And this is pages.xml file fragment:
<page view-id="/search.jsp">
| <param name="category" value="#{search.category}"/>
| <param name="province" value="#{search.province}"/>
| </page>
All this behaves strange. When I enter search.jsp page for the first time, searchResults are just initialized and it's ok. But then I set e.g. category to A, and province to B, and hit the button. In debug I can see _first_ factory method is called, and retrieves articles based on still null province and category, _after_this_ province is set to B and category to A. If I change category and province again, lets say to C and D, and hit the button again I can see such actions in debug:
1. category and province set to A and B (old values)
2. factory method called
3. category and province set to C and D.
Why it happens? Why parameters are not set before calling factory method?
Best regards
Pawel Stawicki
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4114832#4114832
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4114832
18 years, 4 months