openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "sravan (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (OPENJPA-2497) Unable to persist a new instance
Date Tue, 06 May 2014 12:26:16 GMT

    [ https://issues.apache.org/jira/browse/OPENJPA-2497?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13990582#comment-13990582
] 

sravan commented on OPENJPA-2497:
---------------------------------

Hi Rick, 

Please find the details as below. 
1. contents of com.setmr.acsrt.domain
package com.setmr.acsrt.domain;
import static com.setmr.acstr.domain.enums.BooleanAsChar.FALSE;
import static com.setmr.acstr.domain.enums.BooleanAsChar.TRUE;

import java.io.Serializable;
import java.util.Date;
import java.util.LinkedHashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.TableGenerator;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;

import org.apache.openjpa.persistence.DataCache;

import com.setmr.acstr.domain.audit.AuditInterceptor;
import com.setmr.acstr.domain.audit.AuditSupport;
import com.setmr.acstr.domain.audit.Auditable;
import com.setmr.acstr.domain.enums.ScreeningCaseStatus;
import com.setmr.acstr.domain.enums.ScreeningType;

@Entity
@Table(name = "CASES")
@DataCache(enabled = false)
@EntityListeners({ AuditInterceptor.class })
@NamedQueries(value = {
		@NamedQuery(name = Case.SELECT_VERSION, query = "SELECT c.version FROM Case c where c.id
= :id"),
		@NamedQuery(name = Case.SELECT_CASES_IN_ID_LIST, query = "SELECT c FROM Case c where c.id
IN (:idList)") })
public class Case extends AuditSupport implements Serializable {

	private static final long serialVersionUID = -6011881988364962345L;

	public static final String NATIVE_QUERY_CASE_GET_CASE_ID = "select GEN_CASE_ID_FUNCTION()
from dual";
	public static final String SELECT_VERSION = "SELECT_VERSION";

	public static final String SELECT_CASES_IN_ID_LIST = "SELECT_CASES_IN_ID_LIST";
	public static final String ID_LIST = "idList";

	// query params params
	public static final String PARAM_SUBMITED = "submited";
	public static final String NATIVE_QUERY_FIND_UNRESOLVED_CASES = "select c.id_case from cases
c, screening_items s "+
				"WHERE s.status NOT IN('FAIL', 'PASS') "+ 
				"AND c.status = 'UNDER_INVESTIGATION' "+ 
                "AND s.id_case = c.id_case "+ 
                "AND s.expected_alerts != s.received_alerts "+ 
                "AND s.expected_alerts = (SELECT count(A.id_alert) FROM alerts A WHERE A.screening_item_id
= s.id_screening_item "+
                "AND A.status <> 'RE_OPENED' "+
                "AND A.status <> 'UNDER_INVESTIGATION') ";

	public Case() {
		super();
		this.isSubmitLastAction = FALSE.getAsChar();
		this.submited = FALSE.getAsChar();
	}

	@Auditable
	@Column(name = "CASE_REF_NO", length = 50, unique = true)
	private String caseRefNo;

	@TableGenerator(name = "caseGen", table = "ID_GEN", pkColumnName = "GEN_KEY", valueColumnName
= "GEN_VALUE", pkColumnValue = "ID_CASE", allocationSize = 1)
	@Id
	@GeneratedValue(strategy = GenerationType.TABLE, generator = "caseGen")
	@Column(name = "ID_CASE")
	private Integer id;

	@Version
	@Column(name = "VERSION")
	private int version;

	@Column(name = "SCREENING_TYPE", nullable = true, length = 50)
	@Enumerated(EnumType.STRING)
	private ScreeningType screeningType;

	@Auditable
	@Column(name = "STATUS", length = 50)
	@Enumerated(EnumType.STRING)
	private ScreeningCaseStatus status;

	@Auditable
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "FIRST_SCREENING_DATE", columnDefinition = "DATE")
	private Date firstScreeningDate;

	@Auditable
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "LAST_SCREENING_DATE", columnDefinition = "DATE")
	private Date lastScreeningDate;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "LAST_UPDATED_DATE", columnDefinition = "DATE")
	private Date lastUpdatedDate;

	@Auditable
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "SYSTEM_LAST_UPDATED_DATE", columnDefinition = "DATE")
	private Date systemLastUpdatedDate;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "CREATE_DATE", columnDefinition = "DATE")
	private Date createDate;

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "ID_USER_MAKER", nullable = false)
	private User maker;

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "ID_USER_UPDATER", nullable = false)
	private User updater;

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "ID_USER_CHECKER", nullable = true)
	private User checker;

	@Column(name = "SUBMIT_LAST_ACTION", nullable = false, columnDefinition = "CHAR(1)")
	private char isSubmitLastAction;
	
	@Auditable
	@Column(name = "SUBMITED", nullable = false, columnDefinition = "CHAR(1)")
	private char submited;

	@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, mappedBy = "parentCase")
	@OrderBy("id DESC")
	private Set<ScreeningItem> screeningItems = new LinkedHashSet<ScreeningItem>(
			3);

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "ID_BU", nullable = false)
	private BusinessUnit businessUnit;

	@Auditable
	@Column(name = "QA_CHECKED", nullable = false, columnDefinition = "CHAR(1)")
	private char qaChecked;

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "QA_CHECK_DATE", columnDefinition = "DATE")
	private Date qaCheckDate;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public int getVersion() {
		return version;
	}

	public void setVersion(int version) {
		this.version = version;
	}

	public ScreeningType getScreeningType() {
		return screeningType;
	}

	public void setScreeningType(ScreeningType screeningType) {
		this.screeningType = screeningType;
	}

	public ScreeningCaseStatus getStatus() {
		return status;
	}

	public void setStatus(ScreeningCaseStatus status) {
		this.status = status;
	}

	public Date getFirstScreeningDate() {
		return firstScreeningDate;
	}

	public void setFirstScreeningDate(Date firstScreeningDate) {
		this.firstScreeningDate = firstScreeningDate;
	}

	public Date getLastScreeningDate() {
		return lastScreeningDate;
	}

	public void setLastScreeningDate(Date lastScreeningDate) {
		this.lastScreeningDate = lastScreeningDate;
	}

	public User getMaker() {
		return maker;
	}

	public void setMaker(User maker) {
		this.maker = maker;
	}

	public User getUpdater() {
		return updater;
	}

	public void setUpdater(User updater) {
		this.updater = updater;
	}

	public User getChecker() {
		return checker;
	}

	public void setChecker(User checker) {
		this.checker = checker;
	}

	public boolean getSubmited() {
		return submited == TRUE.getAsChar() ? true : false;
	}

	public void setSubmited(boolean submited) {
		this.submited = (submited ? TRUE.getAsChar() : FALSE.getAsChar());
	}

	public boolean getIsSubmitLastAction() {
		return isSubmitLastAction == TRUE.getAsChar() ? true : false;
	}

	public void setIsSubmitLastAction(boolean submited) {
		this.isSubmitLastAction = (submited ? TRUE.getAsChar() : FALSE.getAsChar());
	}

	public String getCaseRefNo() {
		return caseRefNo;
	}

	public void setCaseRefNo(String caseRefNo) {
		this.caseRefNo = caseRefNo;
	}

	public void addScreeningItem(ScreeningItem item) {
		getScreeningItems().add(item);
		item.setParentCase(this);
	}

	public Set<ScreeningItem> getScreeningItems() {
		return screeningItems;
	}

	public void setScreeningItems(Set<ScreeningItem> screeningItems) {
		this.screeningItems = screeningItems;
	}

	public BusinessUnit getBusinessUnit() {
		return businessUnit;
	}

	public void setBusinessUnit(BusinessUnit businessUnit) {
		this.businessUnit = businessUnit;
	}

	public Date getLastUpdatedDate() {
		return lastUpdatedDate;
	}

	public void setLastUpdatedDate(Date lastUpdatedDate) {
		this.lastUpdatedDate = lastUpdatedDate;
	}

	public boolean getQaChecked() {
		return this.qaChecked == TRUE.getAsChar() ? true : false;
	}

	public void setQaChecked(boolean checked) {
		this.qaChecked = (checked ? TRUE.getAsChar() : FALSE.getAsChar());
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public Date getSystemLastUpdatedDate() {
		return systemLastUpdatedDate;
	}

	public void setSystemLastUpdatedDate(Date systemLastUpdatedDate) {
		this.systemLastUpdatedDate = systemLastUpdatedDate;
	}

	public Date getQaCheckDate() {
		return qaCheckDate;
	}

	public void setQaCheckDate(Date qaCheckDate) {
		this.qaCheckDate = qaCheckDate;
	}

	@Override
	public Integer getPk() {
		return id;
	}

	@Override
	public Class<?> getAuditableClass() {
		return Case.class;
	}

	@Override
	public Integer getParentPk() {
		return null;
	}

}


> Unable to persist a new instance
> --------------------------------
>
>                 Key: OPENJPA-2497
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-2497
>             Project: OpenJPA
>          Issue Type: Bug
>            Reporter: sravan
>
> My application is working fine with Websphere 7.0.0.9 since last two years. Now Websphere
is upgraded to version 7.0.0.31. After this upgrade, application is throwing below error while
trying to persist a new instance. Please advise. 
> (Note: In another environment , where I use openjpa-1.2.2 jar with jboss application
server, application is working fine.)
> The below error shows the application is using openjpa-1.2.4-SNAPSHOT. So is there any
such issue in this release that does not exist in openjpa-1.2.2 ? How to remediate it in the
version openjpa-1.2.4-SNAPSHOT ? 
> Will be looking forward for your advise.  
> [12/03/14 08:09:42:885 GMT] 00000038 BusinessExcep E   CNTR0020E: EJB threw an unexpected
(non-declared) exception d
> uring invocation of method "create" on bean "BeanId(acstr01-acstr#acstr-ejb-1.0.jar#CRUDServiceBean,
null)". Excepti
> on data: <openjpa-1.2.4-SNAPSHOT-r422266:1517039 nonfatal store error> org.apache.openjpa.persistence.EntityExistsEx
> ception: Attempt to persist detached object "com.setmar.acstr.domain.Case@4aba4aba".
 If this is a new instance, m
> ake sure any version and/or auto-generated primary key fields are null/default when persisting.
> FailedObject: com.setmar.acstr.domain.Case@4aba4aba
>         at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2453)
>         at org.apache.openjpa.kernel.BrokerImpl.persist(BrokerImpl.java:2312)
>         at org.apache.openjpa.kernel.DelegatingBroker.persist(DelegatingBroker.java:1021)
>         at org.apache.openjpa.persistence.EntityManagerImpl.persist(EntityManagerImpl.java:651)
>         at com.ibm.ws.jpa.management.JPAExEmInvocation.persist(JPAExEmInvocation.java:339)
>         at com.ibm.ws.jpa.management.JPAEntityManager.persist(JPAEntityManager.java:133)
>         at com.setmar.acstr.service.CRUDServiceBean.create(CRUDServiceBean.java:34)
>         at com.setmar.acstr.service.EJSLocal0SLCRUDServiceBean_a178a2d2.create(EJSLocal0SLCRUDServiceBean_a178a2d2
> .java)
>         at com.setmar.acstr.casemgmt.service.CaseServiceBean.save(CaseServiceBean.java:42)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
>         at java.lang.reflect.Method.invoke(Method.java:611)
>         at com.ibm.ejs.container.EJSContainer.invokeProceed(EJSContainer.java:5874)
>         at com.ibm.ejs.container.interceptors.InvocationContextImpl.proceed(InvocationContextImpl.java:586)
>         at com.setmar.acstr.domain.audit.AuditServiceInterceptor.process(AuditServiceInterceptor.java:36)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
>         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
>         at java.lang.reflect.Method.invoke(Method.java:611)
>         at com.ibm.ejs.container.interceptors.InterceptorProxy.invokeInterceptor(InterceptorProxy.java:227)
>         at com.ibm.ejs.container.interceptors.InvocationContextImpl.proceed(InvocationContextImpl.java:566)
>         at com.ibm.ejs.container.interceptors.InvocationContextImpl.doAroundInvoke(InvocationContextImpl.java:217)
>         at com.ibm.ejs.container.EJSContainer.invoke(EJSContainer.java:5766)
>         at com.setmar.acstr.casemgmt.service.EJSLocal0SLCaseServiceBean_78acc083.save(EJSLocal0SLCaseServiceBean_7
> 8acc083.java)
>         at com.setmar.acstr.casemgmt.facade.CaseFacadeBean.submitCase(CaseFacadeBean.java:102)
>         at com.setmar.acstr.casemgmt.facade.EJSLocal0SLCaseFacadeBean_28e75513.submitCase(EJSLocal0SLCaseFacadeBea
> n_28e75513.java)
>         at com.setmar.acstr.managed.AbstractCaseBean.submitCase(AbstractCaseBean.java:232)
>         at com.setmar.acstr.managed.AbstractCaseBean.submitCase(AbstractCaseBean.java:150)



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message