Persistent-new to Transient
I have a query which returns a collection of objects, some of which are
persistent-new and some of which are persistent-clean.
I'd like to make the collection transient so that I can use it outside
the transaction, but the persistent new instances can't be made
transient. Why does a persistent new instance need to behave differently
in this respect? Any suggestions?
Thanks,
Tom
Abe White wrote:
I'd like to make the collection transient so that I can use it outside
the transaction, but the persistent new instances can't be made
transient. Why does a persistent new instance need to behave differently
in this respect? Any suggestions?I'd guess the spec reason is that some implementations might immediately
issue an INSERT when the instance is made persistent. So there's no "backing
out" without rolling back the transaction.Yes, I'm not wanting to back out the makePersistent (you can transition
to persistent-new-deleted to do that), I just want to get transient
copies of all my persistent instances, whether I created them in this
transaction or a previous one.
Tom
Similar Messages
-
I have some Runbooks that must make upwards up 50,000 calls to various web services. I am already leveraging parallel activities but these are still required to generate a Proxy.
I haven't been able to persist a web proxy between .net activities in the same Runbook. I'm also open to using the object below if that is possible.
$endpoint=New-Object System.servicemodel.endpointaddress("")
Would the PowerShell IP be appropriate in this case?
Moved OnSee Kappy's previous write-up.
Some Solutions for Resetting Forgotten Security Questions: Apple Support Communities -
[persistence] all work, but can't persist new entity bean
Hi,
I have a FacadeBean which is working fine ... I can contact the BD oracle for retrieving my entity beans, update an entity bean etc...
BUT... I can't create an entity bean :( I don't understand why!!!
With the same code, I can create, list, etc... on OC4J and JBoss but the create method won't work with WebLogic :|
Here is the error present in console:
<09-mars-2007 15 h 03 min 47 s CET> <Error> <EJB> <BEA-010026> <Exception occurr
ed during commit of transaction Name=[EJB be.starapic.test.ejb.MyEntityFacadeBea
n.create(be.starapic.test.ejb.MyEntity)],Xid=BEA1-007A82AF3A953057A4BD(30283302)
,Status=Rolled back. [Reason=weblogic.transaction.internal.AppSetRollbackOnlyExc
eption],numRepliesOwedMe=0,numRepliesOwedOthers=0,seconds since begin=1,seconds
left=30,XAServerResourceInfo[weblogic.jdbc.wrapper.JTSXAResourceImpl]=(ServerRes
ourceInfo[weblogic.jdbc.wrapper.JTSXAResourceImpl]=(state=rolledback,assigned=Ad
minServer),xar=weblogic.jdbc.wrapper.JTSXAResourceImpl@110563c,re-Registered = f
alse),SCInfo[base_domain+AdminServer]=(state=rolledback),properties=({weblogic.t
ransaction.name=[EJB be.starapic.test.ejb.MyEntityFacadeBean.create(be.starapic.
test.ejb.MyEntity)], weblogic.jdbc=t3://192.168.100.188:7001}),OwnerTransactionM
anager=ServerTM[ServerCoordinatorDescriptor=(CoordinatorURL=AdminServer+192.168.
100.188:7001+base_domain+t3+, XAResources={weblogic.jdbc.wrapper.JTSXAResourceIm
pl},NonXAResources={})],CoordinatorURL=AdminServer+192.168.100.188:7001+base_dom
ain+t3+): weblogic.transaction.RollbackException: Unknown reason
at weblogic.transaction.internal.TransactionImpl.throwRollbackException(
TransactionImpl.java:1808)
at weblogic.transaction.internal.ServerTransactionImpl.internalCommit(Se
rverTransactionImpl.java:333)
at weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTran
sactionImpl.java:227)
at weblogic.ejb.container.internal.BaseRemoteObject.postInvoke1(BaseRemo
teObject.java:606)
at weblogic.ejb.container.internal.BaseRemoteObject.postInvokeTxRetry(Ba
seRemoteObject.java:426)
at weblogic.ejb.container.internal.StatefulRemoteObject.postInvokeTxRetr
y(StatefulRemoteObject.java:100)
at be.starapic.test.ejb.myentityfacade_opn58i_MyEntityFacadeRemoteImpl.c
reate(myentityfacade_opn58i_MyEntityFacadeRemoteImpl.java:158)
at be.starapic.test.ejb.myentityfacade_opn58i_MyEntityFacadeRemoteImpl_C
BV.create(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(Remote
BusinessIntfProxy.java:42)
at $Proxy152.create(Unknown Source)
at be.starapic.test.web.HelloServlet.doGet(HelloServlet.java:88)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run
(StubSecurityHelper.java:226)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecuri
tyHelper.java:124)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.jav
a:283)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.jav
a:175)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
n.run(WebAppServletContext.java:3334)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Authenticate
dSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppS
ervletContext.java:2081)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletC
ontext.java:1987)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.j
ava:1359)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:200)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:172)
.>
<09-mars-2007 15 h 03 min 47 s CET> <Error> <HTTP> <BEA-101020> <[weblogic.servl
et.internal.WebAppServletContext@144a314 - appName: 'testDeploy', name: '/testDe
ploy', context-path: '/testDeploy'] Servlet failed with Exception
javax.ejb.EJBException: nested exception is: weblogic.transaction.internal.AppSe
tRollbackOnlyException
at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(Remote
BusinessIntfProxy.java:57)
at $Proxy152.create(Unknown Source)
at be.starapic.test.web.HelloServlet.doGet(HelloServlet.java:88)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
Truncated. see log file for complete stacktrace
That say nothing good...
at $Proxy152.create(Unknown Source) is the problem I think but why ...?
Here is the entity bean:
@Entity
@Table(name="table_myentity")
public class MyEntity implements Serializable
private static final long serialVersionUID = -5806278646729410835L;
private int id;
private String name;
private int number;
public void setName(String name) {
this.name = name;
public String getName() {
return name;
public void setNumber(int number) {
this.number = number;
@Column(name="mynumber")
public int getNumber() {
return number;
public void setId(int id) {
this.id = id;
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
public int getId() {
return id;
May be a problem of auto-generate for the ID...
Here is the facade bean:
@Stateful(name="myentityfacade", mappedName="myentityfacade")
@Remote(MyEntityFacadeRemote.class)
@Local(MyEntityFacadeLocal.class)
public class MyEntityFacadeBean implements MyEntityFacadeRemote, MyEntityFacadeLocal {
@PersistenceContext
private EntityManager em;
public MyEntity create(MyEntity meb) {
em.persist(meb);
return meb;
public void update(MyEntity meb) throws IllegalAccessException {
if (null == em.find(MyEntity.class, meb.getId())) {
throw new IllegalAccessException("Attempt to update a non existing entity");
em.merge(meb);
public void delete(int id) {
MyEntity meb = em.find(MyEntity.class, id);
em.remove(meb);
public void delete(MyEntity meb) {
meb = em.merge(meb);
em.remove(meb);
public MyEntity findById(int id) {
return em.find(MyEntity.class, id);
public List<MyEntity> listAll() {
return em.createQuery("SELECT o FROM MyEntity AS o").getResultList(); //TOPLINK, HIBERNATE
public List<MyEntity> listFiltered(String filter) {
return em.createQuery("SELECT o FROM MyEntity AS o "+filter).getResultList(); //TOPLINK, HIBERNATE
public int getNbMyEntityBean() {
return this.listAll().size();
Sorry for the long post... And finnaly here is the code present in the servlet:
// CREATE
MyEntity meb1 = new MyEntity();
meb1.setName("bbb");
meb1.setNumber(2);
meb1 = remoteMyEntityFacade.create(meb1);
Note that the remoteMyEntityFacade is working, because I can call any other buisness method without crashing the application.. Just the create can't work and so, persistence can't be used :(
Any suggestions ?There is a problem with generated key
that code won't work:
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
public int getId() {
return id;
But, if I remove line "GeneratedValue", it can insert into the BD, once only :s
The ID is set to 0 by default, so I can't add more than one entity :s -
Switch between transient and persistent objects?
Hi Folks,
I'm Re: transient object to persistent to ask this type of question, but couldn't find an answer.
Using persistent classes, does anyone know an elegant way to convert a transient object to a persistent one and vice versa? There is no standard functionality provided that I can see, and cloning the object results in clashing keys.
What am I trying to accomplish?
I need an object instance which <i>may</i> exist in the DB and if not, it <i>may</i> need to be saved for future use. I'm using a table with key fields K1 and K2 and the app will ask for an object instance using the full key K1+K2.
If the object doesn't find a DB record for K1K2 then it should instantiate itself with values for K1blank. Here is where I'm considering transient in order to provide the app with default functionality defined in record K1+blank.
If a write access occurs to a transient object then is should become persistent and the K1+K2 record be created.
Any ideas appreciated.
Cheers,
MikeHi Mike,
I written something similar working on Persistent Objects.
The only point of attention is that you cannot create a new persistent while a transient is resident in memory.
This is checked by the OS system during the creation of a new persistent:
in method CREATE_PERSISTENT of Basis Class, there is a check on the existing object:
* Precondition : No object exists with the given business key, neither
* in memory nor on database.
So, you can create a new transient, fill it with the values you need and then pass this values to the agent to create a new persistent, but only after releasing the existing transient (because they will have the same key).
I've solved the problem like this:
METHOD flush.
"IMPORTING value(im_transient) TYPE REF TO zcl_liquidate_daily_bo
"IMPORTING value(im_commit) TYPE xfeld
"IMPORTING value(im_agent) TYPE REF TO zca_liquidate_daily_bo
"RETURNING value(re_persistent) TYPE REF TO zcl_liquidate_daily_bo
"--> raised by event PERNR_PROCESSED
DATA: s_dip_liq TYPE zhr_tm_dip_liq.
s_dip_liq-zpernr = im_transient->get_employee_no( ).
s_dip_liq-zsocmat = im_transient->get_matricola_legale( ).
s_dip_liq-zdataev = im_transient->get_event_date( ).
s_dip_liq-zcodev = im_transient->get_event_type( ).
s_dip_liq-zdescev = im_transient->get_event_descr( ).
s_dip_liq-zmotev = im_transient->get_event_reasn( ).
s_dip_liq-zmeseall = im_transient->get_mese_allineamento( ).
s_dip_liq-zannoall = im_transient->get_anno_allineamento( ).
* // Invalidate the transient before create the persistent!
im_agent->if_os_factory~release( im_transient ).
CLEAR im_transient.
IF im_commit EQ abap_true.
TRY.
re_persistent =
im_agent->create_persistent( EXPORTING i_anno_allineamento = s_dip_liq-zannoall
i_mese_allineamento = s_dip_liq-zmeseall
i_employee_no = s_dip_liq-zpernr
i_event_date = s_dip_liq-zdataev
i_event_type = s_dip_liq-zcodev
i_event_descr = s_dip_liq-zdescev
i_event_reasn = s_dip_liq-zmotev
i_matricola_legale = s_dip_liq-zsocmat ).
CATCH cx_os_object_existing.
ENDTRY.
COMMIT WORK AND WAIT.
ENDIF.
ENDMETHOD.
This method is called inside a loop on a table that containes references to transient objects.
For each object I perform some tasks, and if all it's ok I raise the event PERNR_PROCESSED, which automatically calls this method FLUSH, transferring the transient to the persistent.
Return Object is the new persistent, which will be passed back to the internal table, changing the content from the transient to the new persistent.
Hope this helps,
Roby. -
How to model parent child relationship with DPL? @Transient?
Hello All,
I want to model a parent entity object with a collection of child entities:
@Entity
public class Parent{
@PrimaryKey
String uuid;
List<Child> children;
@Entity
public class Child{
@PrimaryKey
String id;
I know that the DPL won't support automatic persistence where it'll recursively go through my parent bean and persist my children with one call. Is there a way of applying the equivalent to JPA's @Transient annotation on "children" so I can persist the children manually and have the engine ignore the collection?
If not and I want to return to the user a Parent with a List named "children," do I have to create a new object which is identical to Parent, but doesn't have the BDB annotations and manually assemble everything? If possible, I'd like to avoid defining redundant objects.
Thanks in advance,
Steven
Harvard Children's Hospital Informatics Program
Edited by: JavaGeek_Boston on Oct 29, 2008 2:22 PMHi Steven,
The definition of persistence is here:
http://www.oracle.com/technology/documentation/berkeley-db/je/java/com/sleepycat/persist/model/Entity.html
And includes this: "All non-transient instance fields of an entity class, as well as its superclasses and subclasses, are persistent. static and transient fields are not persistent."
So you can use the Java transient keyword. If that isn't practical because you're using transient in a different way for Java serialization, see the JE @NotPersistent annotation.
In general a parent-child relationship between entities is implemented almost as you've described, but with a parentId secondary key in the Child to index all children by their parent. This enables a fast lookup of children by their parent ID.
I suggest looking at this javadoc:
http://www.oracle.com/technology/documentation/berkeley-db/je/java/com/sleepycat/persist/SecondaryIndex.html
as it describes all types of entity relationships and the trade-offs involved. The department-employee relationship in these examples is a parent-child relationship.
--mark -
JDeveloper 12.c - Entity Object Transient Attribute Behavior
Hi
Just wondering if the following behaviour is the expected one for a new attribute in an Entity Object;
The only way to be allowed to write an expression as default value is if the attribute itself is persistent. If transient is selected, the only available option for default value is SQL. So I need to put as persistent momentarily while writing my expression and then change it to transient.
RegardsHi,
no, this is not intended. If you have a support contract or internal access to the bug database, please file a bug
Frank -
Programmatically creating new desktops?
I'd like to be able to create (and persist) new Portal desktops from a given template without using the PortalAdminTool.
Can someone please provide a link or example of how to create a desktop like this from a JSP?
Thanks
MikeI don't think this is supported OOTB. You might want to go through the code in portaladmin to find some hidden API's :)
Kunal Mittal -
Weblogic seems to swallow Oracle Exception
Hi,
Weblogic seems to swallow the Oracle Exception when using EntityManager, can someone also verify this ?
Here is what I did:
SQL> create table AMS_TEST (TEST_ID INTEGER primary key, name VARCHAR2(125), CONSTRAINT X UNIQUE (name));
Table created.
SQL> CREATE SEQUENCE SEQ_TEST_ID;
Sequence created.
And EJB 3 Been as follows:
@Entity
@Table(name = "AMS_TEST")
@SequenceGenerator(name="seg_test_id_gen", sequenceName = "SEQ_TEST_ID")
public class DummyBean {
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seg_test_id_gen")
@Column(name = "TEST_ID", length =38)
private Long mTestId;
@Column(name = "NAME", length =125)
private String mName;
public DummyBean(String name) {
mName = name;
public String getName() {
return mName;
And the in StateSessionBean method
public void test() {
getEntityManager().persist(new DummyBean("test"));
If the method call twice, it should throw an Oracle's Unique constraint exception due to the unique constraint on "name".
But instead, weblogic only throws "Unknown reason" exception.
Is there a way to report the real exception so that one know that's the cause of failure ?
Chester
<Feb 8, 2008 9:01:21 PM PST> <Error> <EJB> <BEA-010026> <Exception occurred during commit of transaction Name=[EJB com.ascentmedia.ams.content.AssetManagerBean.test()],Xid=BEA1-00187801BCA41A74F1B8(9411978),Status=Rolled back. [Reason=weblogic.transaction.internal.AppSetRollbackOnlyException],numRepliesOwedMe=0,numRepliesOwedOthers=0,seconds since begin=0,seconds left=60,NonXAServerResourceInfo[WL_JDBC_LLR_POOL.AMS_DS]=(ServerResourceInfo[WL_JDBC_LLR_POOL.AMS_DS]=(state=rolledback,assigned=AdminServer),nonXAResource=JDBC LLR, pool=AMS_DS, table=WL_LLR_ADMINSERVER),SCInfo[ams3+AdminServer]=(state=rolledback),properties=({weblogic.transaction.nonXAResource=WL_JDBC_LLR_POOL.AMS_DS, weblogic.transaction.name=[EJB com.ascentmedia.ams.content.AssetManagerBean.test()], weblogic.jdbc=t3://192.168.2.8:7001, weblogic.jdbc.llr=AMS_DS}),OwnerTransactionManager=ServerTM[ServerCoordinatorDescriptor=(CoordinatorURL=AdminServer+192.168.2.8:7001+ams3+t3+, XAResources={WLStore_ams3__WLS_AdminServer, WLStore_ams3_JDBCStore},NonXAResources={})],CoordinatorURL=AdminServer+192.168.2.8:7001+ams3+t3+): weblogic.transaction.RollbackException: Unknown reason
at weblogic.transaction.internal.TransactionImpl.throwRollbackException(TransactionImpl.java:1818)
at weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTransactionImpl.java:333)
at weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransactionImpl.java:227)
at weblogic.ejb.container.internal.BaseRemoteObject.postInvoke1(BaseRemoteObject.java:611)
at weblogic.ejb.container.internal.StatelessRemoteObject.postInvoke1(StatelessRemoteObject.java:57)
at weblogic.ejb.container.internal.BaseRemoteObject.postInvokeTxRetry(BaseRemoteObject.java:431)
at com.ascentmedia.ams.content.AssetManagerBean_whuwo6_AssetManagerRemoteImpl.test(AssetManagerBean_whuwo6_AssetManagerRemoteImpl.java:1677)
at com.ascentmedia.ams.content.AssetManagerBean_whuwo6_AssetManagerRemoteImpl_WLSkel.invoke(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:586)
at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:474)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:470)
at weblogic.rmi.internal.wls.WLSExecuteRequest.run(WLSExecuteRequest.java:118)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
.>I am getting a similar error with an Hibernate implementation of EntityManager. I had an error on my code that made a EntityManager#persist call on a entity that had another transient entity setted in a ManyToOne relationship that weren't tagged with cascade anotation.
The only way I managed to dig for the error was to force a EntityManager#flush on my EJB bean code that happily threw the correct exception (IllegalStateException, which is correctly documented on section 3.2.3 of the EJB 3.0 specification - persistence).
There should be a standard way to retrieve the cause of an rollback from a EJB call that the EntityManager throws during commit. Without that, it will be kind of difficult to rely on container managed transaction.
This was the stack trace I got on my log:
####<18/02/2008 16h22min33s BRT> <Error> <EJB> <rcouto> <AdminServer> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <> <1203362553258> <BEA-010026> <Exception occurred during commit of transaction Name=[EJB br.com.touchtec.lsd.impl.LSDBean.createScript(java.lang.String,java.util.Locale,java.lang.String,br.com.touchtec.net.Reference)],Xid=BEA1-0000B42F7CD37B374FDD(27009473),Status=Rolled back. [Reason=weblogic.transaction.internal.AppSetRollbackOnlyException],numRepliesOwedMe=0,numRepliesOwedOthers=0,seconds since begin=1,seconds left=30,XAServerResourceInfo[weblogic.jdbc.wrapper.JTSXAResourceImpl]=(ServerResourceInfo[weblogic.jdbc.wrapper.JTSXAResourceImpl]=(state=rolledback,assigned=AdminServer),xar=weblogic.jdbc.wrapper.JTSXAResourceImpl@16c0ff5,re-Registered = false),SCInfo[lsd+AdminServer]=(state=rolledback),properties=({weblogic.transaction.name=[EJB br.com.touchtec.lsd.impl.LSDBean.createScript(java.lang.String,java.util.Locale,java.lang.String,br.com.touchtec.net.Reference)], weblogic.jdbc=t3://172.19.64.51:7001}),OwnerTransactionManager=ServerTM[ServerCoordinatorDescriptor=(CoordinatorURL=AdminServer+172.19.64.51:7001+lsd+t3+admin+7001+, XAResources={weblogic.jdbc.wrapper.JTSXAResourceImpl},NonXAResources={})],CoordinatorURL=AdminServer+172.19.64.51:7001+lsd+t3+admin+7001+): weblogic.transaction.RollbackException: Unknown reason
at weblogic.transaction.internal.TransactionImpl.throwRollbackException(TransactionImpl.java:1818)
at weblogic.transaction.internal.ServerTransactionImpl.internalCommit(ServerTransactionImpl.java:333)
at weblogic.transaction.internal.ServerTransactionImpl.commit(ServerTransactionImpl.java:227)
at weblogic.ejb.container.internal.BaseRemoteObject.postInvoke1(BaseRemoteObject.java:606)
at weblogic.ejb.container.internal.StatelessRemoteObject.postInvoke1(StatelessRemoteObject.java:57)
at weblogic.ejb.container.internal.BaseRemoteObject.postInvokeTxRetry(BaseRemoteObject.java:426)
at br.com.touchtec.lsd.impl.LSDBean_jz0i8w_LSDImpl.createScript(LSDBean_jz0i8w_LSDImpl.java:153)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(RemoteBusinessIntfProxy.java:63)
at $Proxy69.createScript(Unknown Source)
at br.com.touchtec.lsd.it.web.ScriptAction.save(ScriptAction.java:89)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at br.com.touchtec.twf.core.TWFActionInvocation.invokeAction(TWFActionInvocation.java:98)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:267)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:229)
at br.com.touchtec.twf.validation.WorkflowInterceptor.doIntercept(WorkflowInterceptor.java:91)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
at br.com.touchtec.twf.validation.ValidationInterceptor.doIntercept(ValidationInterceptor.java:124)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:123)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:121)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:167)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:83)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
at br.com.touchtec.twf.process.ProcessContextInterceptor.intercept(ProcessContextInterceptor.java:104)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
at br.com.touchtec.twf.process.ProcessStackInterceptor.intercept(ProcessStackInterceptor.java:64)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
at br.com.touchtec.twf.userContext.InjectUserContextInterceptor.intercept(InjectUserContextInterceptor.java:54)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
at br.com.touchtec.twf.ejb.EJBInjectorInterceptor.intercept(EJBInjectorInterceptor.java:77)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:170)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
at br.com.touchtec.twf.session.SessionCleanUpInterceptor.intercept(SessionCleanUpInterceptor.java:48)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:221)
at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:50)
at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:504)
at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419)
at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:42)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3368)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(Unknown Source)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2117)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2023)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1359)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:200)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:172)
.> -
Instance not managed by this PM Exception
I'm running into a problem migrating some old code which used to work with
Kodo JDO Enterprise Beta 2.1.3 over to the latest Beta 2.2.1.
The use case involves loading a persistent object A in one PM and then
setting it as a persistent member of a new non-persistent object B (i.e.:
B.setA(A) ). Both A and B are first-class persistence capable objects.
When I then try to persist B by calling makePersistent() on it using another
PM in an optimistic transaction, I get the following exception at commit:
javax.jdo.JDOUserException: The instance is not managed by this
PersistenceManager.
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.makePersistentFilter(Per
sistenceManagerImpl.java:665)
at
com.solarmetric.kodo.runtime.PersistFCOFieldManager.setFirstClassObject(Pers
istFCOFieldManager.java:107)
at
com.solarmetric.kodo.runtime.PersistFCOFieldManager.setObject(PersistFCOFiel
dManager.java:75)
at
com.solarmetric.kodo.runtime.StateManagerImpl.providedObjectField(StateManag
erImpl.java:924)
at MyObject.jdoProvideField(MyObject.java)
at
com.solarmetric.kodo.runtime.StateManagerImpl.provideFields(StateManagerImpl
..java:1222)
at
com.solarmetric.kodo.runtime.StateManagerImpl.persistFirstClassFields(StateM
anagerImpl.java:1171)
at com.solarmetric.kodo.runtime.PNewState.preStore(PNewState.java:31)
at
com.solarmetric.kodo.runtime.StateManagerImpl.preStore(StateManagerImpl.java
:323)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.flush(PersistenceManager
Impl.java:319)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.commit(PersistenceManage
rImpl.java:245)
The failed object in the exception is null. Also note that A has not
changed during the scope of the transaction.
Is this a bug or is this type of operation, involving clean objects managed
by other PMs, no longer supported?
Thanks,
Sasha HaghaniHi Sasha,
I don't think the spec is entirely clear on this point, but the relevant
part of the spec is 12.5.7:
Make instances persistent
These methods make a transient instance persistent directly. They must be
called in the context of an active transaction. They will assign an object
ideentity to the instance and tatrnsition it to persistent-new. During
commit of the transaction in which this instance was made persistent, any
tarnsient instances reachable from this instance via persistent fields of
this instance will became persistent as well.
They have no effect on persistent instances already managed by this
PersistencManager. They will throw a JDOUserException if the instance is
managed by a different PersistenceManager.
It doesn't explicitly say what should happen if one of the reachable objects
is managed by a different PM. It does declare what the behavior should be
for persisting the top-most object, which is do nothing if managed by the
PM, throw an exception if managed by some other PM. In the absence of other
information, it seems reasonable to me to expect this same behavior when the
PM attempts to make the reachable objects persistent, after all, what's the
difference?
In particular, what should happen if an object related to a transient object
is managed by some PM that talks to a totally different database than the
current one, with different primary keys, even persisting different methods
of the object? How could the current PM possibly put such a relation into
the database? In this case, throwing an exception seems like the only
possibility.
I would personally like to see an option where you can indicate to the JDO
implementation that all your PMs are talking to the same db, and that it
shouldn't throw an exception here. It would certainly make my life easier,
along with most people in what I suspect will be a very common situation of
using only really one type of PM, talking to one database, but with multiple
instances for transactional purposes. However, I'm forced to admit that the
spec seems to indicate, to the extent that it indicates anything, the
behavior that Kodo displays.
-Eric
"Sasha Haghani" <[email protected]> wrote in message
news:[email protected]...
Hi Eric,
Thanks for the feedback.
If that is in fact the behavior that's too bad. It seems more limiting.
The way I see it, if the related objects are persistent-clean, then the
other PMs don't really need to get involved and the transaction should be
allowed to complete.
What in particular in the spec is leading you to believe that this is the
correct behavior?
Thanks again,
Sasha Haghani.
"Eric Lindauer" <[email protected]> wrote in message
news:[email protected]...
Hi Sasha,
The problem is that Kodo now throws an exception in a place where itdidn't
used to. I believe this behavior is consistent with the spec. I had to
make quite a few changes to my code to accomodate this same problem.
When
you try to make B persistent, Kodo traverses all the relations in A and
attempting to make any other findable objects persistent. When it runsinto
an object from another PM, it throws an exception.
The way to fix this problem is to ensure that A is first located in the
PM
you are going to use before you attempt to set the relation in B. For
example:
A theA = ... get it however you are now...;
theA = (A) pm.findObjectById ( JDOHelper.getObjectId ( theA ), true );
B theB = new B ( theA );
pm.makePersistent ( theB );
By the way, this type of change is a case-study in why factory methodsare
good. We use them for creating all our objects here, and I imagine this
change would have been a royal pain-in-the-ass if we hadn't.
Hope this helps.
-Eric
"Sasha Haghani" <[email protected]> wrote in message
news:[email protected]...
I'm running into a problem migrating some old code which used to work
with
Kodo JDO Enterprise Beta 2.1.3 over to the latest Beta 2.2.1.
The use case involves loading a persistent object A in one PM and then
setting it as a persistent member of a new non-persistent object B(i.e.:
B.setA(A) ). Both A and B are first-class persistence capable
objects.
>>>
When I then try to persist B by calling makePersistent() on it usinganother
PM in an optimistic transaction, I get the following exception at
commit:
javax.jdo.JDOUserException: The instance is not managed by this
PersistenceManager.
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.makePersistentFilter(Per
sistenceManagerImpl.java:665)
at
com.solarmetric.kodo.runtime.PersistFCOFieldManager.setFirstClassObject(Pers
istFCOFieldManager.java:107)
at
com.solarmetric.kodo.runtime.PersistFCOFieldManager.setObject(PersistFCOFiel
dManager.java:75)
at
com.solarmetric.kodo.runtime.StateManagerImpl.providedObjectField(StateManag
erImpl.java:924)
at MyObject.jdoProvideField(MyObject.java)
at
com.solarmetric.kodo.runtime.StateManagerImpl.provideFields(StateManagerImpl
.java:1222)
at
com.solarmetric.kodo.runtime.StateManagerImpl.persistFirstClassFields(StateM
anagerImpl.java:1171)
atcom.solarmetric.kodo.runtime.PNewState.preStore(PNewState.java:31)
at
com.solarmetric.kodo.runtime.StateManagerImpl.preStore(StateManagerImpl.java
:323)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.flush(PersistenceManager
Impl.java:319)
at
com.solarmetric.kodo.runtime.PersistenceManagerImpl.commit(PersistenceManage
rImpl.java:245)
The failed object in the exception is null. Also note that A has not
changed during the scope of the transaction.
Is this a bug or is this type of operation, involving clean objectsmanaged
by other PMs, no longer supported?
Thanks,
Sasha Haghani -
ComponentView does not redraw component in JTextPane Cell Rend
We have created a JTable implementation that uses JTextPanes as cell renderers/editors so that text styles and the like are available. We want insert a component, such as a JButton, into the JTextPane. However, the component is only visible when the cell is in an editable state. In the renderer, the ComponentView looks like it has set aside the space where the component is to be, but the component is not visible.
I have looked at this problem for several days now, and have only determined that this seems to be occuring at a low level. What I have found is that the ButtonUI's update method is not called when the document is in the cell renderer, while it seems called continuously in the cell editor (on each caret blink).
Does anybody have any insight as to the problem? I have submitted this as a bug to Sun but wanted to find out if anybody else has come across anything similar to this.
Thank for any help.
Steve Feveile
Here is sample code to reproduce the problem:
// Main Class
* Main frame for the testing of the component not painting. This simplifies
* an issue we have come across when trying to set up using a JTextPane as a
* renderer/editor as the cells in a table.
* Under these conditions we have found that a component inserted into the JTextPanes document
* only appears in the editing state of the cell, whereas the rendering state leaves
* the spacing for the component but does not make it visible.
* Note that creating a JTextPane with the one of these documents will show the component,
* even when not editing.
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.table.*;
public class tableFrame extends JFrame
public tableFrame()
//set up frame
getContentPane().setLayout(new BorderLayout());
setSize(500,300);
setTitle("Table Missing Component Test");
addWindowListener(
new WindowAdapter() {
public void windowClosing(WindowEvent e) {
setVisible(false);
System.exit(0);
//set up components the table
JTable table = new JTable(createDocumentTableModel(2,2));
table.setRowHeight(60);
//set the default renderer/editor to use the JTextPane implementation
for (int x = 0; x < table.getColumnCount(); x++) {
table.setDefaultEditor(table.getColumnClass(x), new TextPaneCellEditor());
table.setDefaultRenderer(table.getColumnClass(x), new TextPaneRenderer());
JScrollPane pane = new JScrollPane(table);
getContentPane().add(pane, BorderLayout.CENTER);
//this adds a textpane without the table involved
//uising the same way of inserting a document
JTextPane tPane = new JTextPane();
DefaultStyledDocument doc = new DefaultStyledDocument();
try
doc.insertString(0, "Some text in a JTextPane", null);
JButton b = new JButton("Button");
SimpleAttributeSet inputAttributes = new SimpleAttributeSet();
StyleConstants.setComponent(inputAttributes, b);
doc.insertString(0 , " ", inputAttributes);
catch (Throwable t)
System.out.println("createDocumentTableModel error: " + t.getMessage());
tPane.setDocument(doc);
tPane.setSize(490, 60);
JScrollPane pane2 = new JScrollPane(tPane);
getContentPane().add(pane2, BorderLayout.SOUTH);
* this creates a table model where the documents are the value
* in each cell, and the cell renderer/editor can use this instead
* of a string value
private TableModel createDocumentTableModel(int row, int col)
Vector headerData = new Vector();
Vector tableData = new Vector();
for (int i=0;i<row;i++)
headerData.add("Column" + i);
Vector rowData = new Vector();
for (int j=0;j<col;j++)
DefaultStyledDocument doc = new DefaultStyledDocument();
try
//this inserts some string to see that this is visible
//when editing and rendering
doc.insertString(0, ("Row: " + i + ", Column: " + j), null);
//this button will only be visible when the cell is in
//an editing state
JButton b = new JButton("Button" + i + "-" + j);
SimpleAttributeSet inputAttributes = new SimpleAttributeSet();
StyleConstants.setComponent(inputAttributes, b);
doc.insertString(0 , " ", inputAttributes);
catch (Throwable t)
System.out.println("createDocumentTableModel error: " + t.getMessage());
rowData.add(doc);
tableData.add(rowData);
return new DefaultTableModel(tableData, headerData);
//starts the ball rolling
static public void main(String args[])
(new tableFrame()).setVisible(true);
// Custom Cell Editor
* Sets the editor to use a JTextPane implementation
import java.awt.*;
import java.awt.event.*;
import javax.swing.table.*;
import javax.swing.event.*;
import java.util.EventObject;
import java.io.Serializable;
import javax.swing.*;
import javax.swing.text.*;
public class TextPaneCellEditor implements TableCellEditor
/** Event listeners */
protected EventListenerList listenerList = new EventListenerList();
transient protected ChangeEvent changeEvent = null;
protected JTextPane editorComponent;
protected EditorDelegate delegate;
protected int clickCountToStart = 1;
* constructor.
public TextPaneCellEditor() {
editorComponent = new JTextPane();
//use 1 click count to edit a cell
clickCountToStart = 1;
* controls the values of the editor
delegate = new EditorDelegate() {
* sets the text value cell.
* @param value - value to set in the document
public void setValue(Object value) {
if (value instanceof Document)
editorComponent.setDocument((Document) value);
else
editorComponent.setText("");
* gets the text value cell.
* @return the document in the textpane
public Object getCellEditorValue() {
return editorComponent.getDocument();
// implements the setting the value for the editor
public Component getTableCellEditorComponent(JTable table, Object value,
boolean isSelected, int row, int column) {
if (value != null)
delegate.setValue(value);
else
delegate.setValue("");
return editorComponent;
// Implementing the CellEditor Interface
// implements javax.swing.CellEditor
public Object getCellEditorValue() {
return delegate.getCellEditorValue();
// implements javax.swing.CellEditor
public boolean isCellEditable(EventObject anEvent) {
if (anEvent instanceof MouseEvent) {
return ((MouseEvent)anEvent).getClickCount() >= clickCountToStart;
return true;
// implements javax.swing.CellEditor
public boolean shouldSelectCell(EventObject anEvent) {
return delegate.shouldSelectCell(anEvent);
// implements javax.swing.CellEditor
public boolean stopCellEditing() {
fireEditingStopped();
return true;
// implements javax.swing.CellEditor
public void cancelCellEditing() {
fireEditingCanceled();
// Handle the event listener bookkeeping
// implements javax.swing.CellEditor
public void addCellEditorListener(CellEditorListener l) {
listenerList.add(CellEditorListener.class, l);
// implements javax.swing.CellEditor
public void removeCellEditorListener(CellEditorListener l) {
listenerList.remove(CellEditorListener.class, l);
* Notify all listeners that have registered interest for
* notification on this event type. The event instance
* is lazily created using the parameters passed into
* the fire method.
* @see EventListenerList
protected void fireEditingStopped() {
// Guaranteed to return a non-null array
Object[] listeners = listenerList.getListenerList();
// Process the listeners last to first, notifying
// those that are interested in this event
for (int i = listeners.length-2; i>=0; i-=2) {
if (listeners==CellEditorListener.class) {
// Lazily create the event:
if (changeEvent == null)
changeEvent = new ChangeEvent(this);
((CellEditorListener)listeners[i+1]).editingStopped(changeEvent);
* Notify all listeners that have registered interest for
* notification on this event type. The event instance
* is lazily created using the parameters passed into
* the fire method.
* @see EventListenerList
protected void fireEditingCanceled() {
// Guaranteed to return a non-null array
Object[] listeners = listenerList.getListenerList();
// Process the listeners last to first, notifying
// those that are interested in this event
for (int i = listeners.length-2; i>=0; i-=2) {
if (listeners[i]==CellEditorListener.class) {
// Lazily create the event:
if (changeEvent == null)
changeEvent = new ChangeEvent(this);
((CellEditorListener)listeners[i+1]).editingCanceled(changeEvent);
// Protected EditorDelegate class
protected class EditorDelegate implements ActionListener, ItemListener, Serializable {
//made up of unimplemented methods
protected Object value;
public Object getCellEditorValue() {
return null;
public void setValue(Object x) {}
public void setDocument(Object x) {}
public Document getDocument() {
return null;
public boolean isCellEditable(EventObject anEvent) {
return true;
/** Unfortunately, restrictions on API changes force us to
* declare this method package private.
boolean shouldSelectCell(EventObject anEvent) {
return true;
public boolean startCellEditing(EventObject anEvent) {
return true;
public boolean stopCellEditing() {
return true;
public void cancelCellEditing() {
public void actionPerformed(ActionEvent e) {
fireEditingStopped();
public void itemStateChanged(ItemEvent e) {
fireEditingStopped();
// Custom Cell Renderer
* renders a table cell as a JTextPane.
import java.awt.*;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.table.*;
public class TextPaneRenderer extends JTextPane implements TableCellRenderer
* Constructor - just set to noneditable
public TextPaneRenderer() {
setEditable(false);
* implementation of table cell renderer. If the value is a document
* the, the text panes setDocument is used, otherwise a string value
* is set
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
if (value != null)
if (value instanceof Document)
//set the value to a document
setDocument((Document) value);
else
//convert the value to a string
setText(value.toString());
else
//set text to an empty string
setText("");
return this;Hi, I came across the forum and found your problem is very similar to what I am having now. Your post has been a year old, I just wonder if you come up anything productive to what you had? Could you let us know what you (or Sun) find out if you do have one? Thanks.
-
How can I "beautify" the output of an XML Query
Hi,<br /><br />I created a simple process that executes a SQL query and transforms the data to XML. I've put that variable as an output parameter to see the result.<br /><br />Unfortunately, LCES makes a document element from it with CDATA in it. This is not what I want. I want the nodes to appear directly in my output.<br /><br />Anybody who knows what I should do ?<br /><br />Regards<br />Yves<br /><br /><soapenv:Body><br /> <invokeResponse xmlns="http://adobe.com/idp/services"><br /> <test_data xsi:type="ns1:XML" xmlns:ns1="http://adobe.com/idp/services"><br /> <document><?xml version="1.0"?><br /><xml><row><EventDate type="DATE">2006-02-16</EventDate><Jobs type="INTEGER UNSIGNED">9</Jobs><Pages type="INTEGER UNSIGNED">9</Pages><FirstJob type="TIME">14:06:51</FirstJob><LastJob type="TIME">15:42:32</LastJob></row><row><EventDate type="DATE">2006-02-17</EventDate><Jobs type="INTEGER UNSIGNED">22</Jobs><Pages type="INTEGER UNSIGNED">22</Pages><FirstJob type="TIME">13:13:17</FirstJob><LastJob type="TIME">15:23:00</LastJob></row>
Input.xsl:<br /><br /><?xml version="1.0" encoding="UTF-8" ?> <br />- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:gb="http://adobe.com/idp/services"><br /> <xsl:output method="xml" /> <br />- <xsl:template match="/"><br />- <data><br /> <xsl:value-of select="gb:document" /> <br /> </data><br /> </xsl:template><br /> </xsl:stylesheet><br /><br />SampleXSLT.1.0:<br /><br /><?xml version="1.0" encoding="UTF-8"?><br /><sup:process monitor-access="false" transaction-timeout="-1" transaction-propagation="REQUIRES NEW" type="transient" pof-object-type="" name="USBXSLT" id="P1178311695152" xmlns:jav="http://www.adobe.com/2006/JavaTypes" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:sup="http://adobe.com/workflow/template/support"><sup:description/><sup:variables>< sup:variable visibleInUI="true" searchable="true" description="" title="" pof-attribute="create_time" type="xs:dateTime" required="true" in="false" out="false" name="create_time" id="V1184187125673"><sup:value xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/></sup:variable><sup:variable visibleInUI="true" searchable="true" description="" title="" pof-attribute="creator_id" type="xs:string" required="true" in="false" out="false" name="creator_id" id="V1184187125674"><sup:value xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/></sup:variable><sup:variable visibleInUI="false" searchable="false" description="" title="" pof-attribute="" type="jav:xml" required="false" in="false" out="false" name="dataXML" id="V1184187125678"><sup:property readonly="false" dependent-property="" editor="" description="" name="xsd reference" id="VP1184187126024"/><sup:value xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/></sup:variable><sup:variable visibleInUI="false" searchable="false" description="" title="" pof-attribute="" type="jav:document" required="false" in="false" out="true" name="dataXMLDocument" id="V1184187125679"><sup:value xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/></sup:variable><sup:variable visibleInUI="true" searchable="true" description="" title="" pof-attribute="id" type="xs:long" required="true" in="false" out="false" name="id" id="V1184187125675"><sup:value xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/></sup:variable><sup:variable visibleInUI="false" searchable="false" description="" title="" pof-attribute="inputxml" type="jav:document" required="false" in="true" out="false" name="inputxml" id="V1184187125680"><sup:value xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/></sup:variable><sup:variable visibleInUI="true" searchable="true" description="" title="" pof-attribute="status" type="xs:string" required="true" in="false" out="false" name="status" id="V1184187125676"><sup:value xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/></sup:variable><sup:variable visibleInUI="false" searchable="false" description="" title="" pof-attribute="transformedxml" type="jav:document" required="false" in="false" out="false" name="transformedXML" id="V1184187125681"><sup:value xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/></sup:variable><sup:variable visibleInUI="true" searchable="true" description="" title="" pof-attribute="update_time" type="xs:dateTime" required="true" in="false" out="false" name="update_time" id="V1184187125677"><sup:value xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/></sup:variable><sup:variable visibleInUI="false" searchable="false" description="" title="" pof-attribute="xmlforxsl" type="jav:xml" required="false" in="false" out="false" name="xmlForXSL" id="V1184187125682"><sup:property readonly="false" dependent-property="" editor="" description="" name="xsd reference" id="VP1184187126025"/><sup:value xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/></sup:variable><sup:variable visibleInUI="false" searchable="false" description="" title="" pof-attribute="xslturi" type="jav:string" required="false" in="true" out="false" name="xsltURI" id="V1184187125683"><sup:property readonly="false" dependent-property="" editor="" description="" name="length" id="VP1184187126026"/><sup:value xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/></sup:variable></sup:variables><su p:branch start-action="Get XML from input doc" type="transactional" y-position="0" x-position="0" name="main-branch" id="B1178311695214"><sup:description xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/><sup:pools><sup:pool start-action="Get XML from input doc" y-position="0" x-position="2" type="horizontal" name="POOL" id="PL1178311695214"><sup:description xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/><sup:swimlanes><sup:swimlane type="horizontal" color="RGB{192, 192, 192}" width="2000" height="600" y-position="0" x-position="34" name="SWIMLANE0" id="S1178311695214"><sup:description xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/><sup:actions><sup:invoke operation-name="transformFromURI" service-name="XSLTService" isFireAndForget="false" isLongLived="false" color="" y-position="200" x-position="130" name="Transform using XSLT URL" id="A1178311813709"><sup:description/><sup:routes><sup:route destination="Get Data XML" to-port="TOP_CENTER" from-port="BOTTOM_CENTER" segment-distance="0" segment="0" y-offset="0" x-offset="0" link-type="normal" connective="" name="route1" id="R1178388116299"><sup:description xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/></sup:route></sup:routes><sup:even t-catchs><sup:default-exception-catch position="bottom-right" event-category="Exception" event-type-name="DEFAULT EXCEPTION" operation-name="transformFromURI" name="DEFAULT EXCEPTION" id="EC1178311813787"/></sup:event-catchs><sup:input type="LITERAL" name="factoryName"><sup:value xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/></sup:input><sup:input type="VARIABLE" name="xml"><sup:value>xmlForXSL</sup:value></sup:input><sup:input type="VARIABLE" name="xslt"><sup:value>xsltURI</sup:value></sup:input><sup:output type="VARIABLE" name="result"><sup:value>transformedXML</sup:value></sup:output></sup:invoke><sup:invoke operation-name="execute" service-name="SetValue" isFireAndForget="false" isLongLived="false" color="" y-position="50" x-position="130" name="Get XML from input doc" id="A1178327563980"><sup:description/><sup:routes><sup:route destination="Transform using XSLT URL" to-port="TOP_CENTER" from-port="RIGHT_CENTER" segment-distance="0" segment="0" y-offset="0" x-offset="0" link-type="normal" connective="" name="route0" id="R1178388116296"><sup:description xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/></sup:route></sup:routes><sup:inpu t type="IMPLICIT" name="execution-context"><sup:value xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/></sup:input><sup:input type="LITERAL" name="mappings"><sup:value><list><br /> <com.adobe.idp.workflow.dsc.type.SetValueMapping><br /> <m__locationExpr>/process_data/xmlForXSL</m__locationExpr><br /> <m__valueExpr>/process_data/@inputxml</m__valueExpr><br /> </com.adobe.idp.workflow.dsc.type.SetValueMapping><br /></list></sup:value></sup:input></sup:invoke><sup:invoke operation-name="writeDocument" service-name="FileUtilsService" isFireAndForget="false" isLongLived="false" color="" y-position="200" x-position="325" name="Debug XML" id="A1178464954420"><sup:description/><sup:event-catchs><sup:default-exception-catch position="bottom-right" event-category="Exception" event-type-name="DEFAULT EXCEPTION" operation-name="writeDocument" name="DEFAULT EXCEPTION" id="EC1178467322998"/></sup:event-catchs><sup:input type="LITERAL" name="pathnamePattern"><sup:value>c:\scrap\docdata.xml</sup:value></sup:input><sup:input type="VARIABLE" name="document"><sup:value>dataXMLDocument</sup:value></sup:input><sup:input type="LITERAL" name="makeUnique"><sup:value>t
-
Batch Input Problem with PB10 - Updating IT22 via BDC
Hi out there,
I'm using PB10 to persist new applicants data.
Im processing after save the IT22.
In dialogmode i can just go back without putting input to it22. After going back the new applicant is saved successfully. Now it is possible to use pb30 to maintain (or new creation) of it22 for this applicant.
Now I recorded this "process" and after call transaction the system brings back an error that mandatory field p0022-endda is missing. this error exists also, if i fill the recorded map with data.
Batch Input in Background Mode ->Error
Batch Input in Dialog Mode -> IT22 Dialog appears with empty data
....Using "normal" Dialog Transaction OK!
Here's the code:
PERFORM: bdc_dynpro USING 'SAPMPAP4' '0100',
bdc_field USING 'BDC_OKCODE' '=UPD',
bdc_field USING 'PSPAR-BEGDA' d_beginn,
bdc_field USING 'Q4000-WERKS' '0001',
bdc_field USING 'P0001-BTRTL' '0001',
bdc_field USING 'Q4000-APGRP' '1',
bdc_field USING 'Q4000-APTYP' aptyp,
bdc_field USING 'Q0002-ANREX' anrex,
bdc_field USING 'P0002-VORNA' vorna,
bdc_field USING 'P0002-NACHN' nachn,
bdc_field USING 'Q0002-GBPAS' d_gbpas,
bdc_field USING 'P0002-SPRSL' sprac,
bdc_field USING 'P0002-NATIO' natio,
bdc_field USING 'P0006-LAND1' land1,
bdc_field USING 'P0006-STRAS' stras,
bdc_field USING 'P0006-PSTLZ' pstlz,
bdc_field USING 'P0006-ORT01' ort01,
bdc_field USING 'P0006-TELNR' telnr,
bdc_field USING 'EMAIL' stamm-email,
bdc_field USING 'P4001-SPAPL' aptyp,
*IT22
bdc_dynpro USING 'MP002200' '2000',
bdc_field USING 'BDC_OKCODE' '=UPD',
bdc_field USING 'P0022-BEGDA' d_beginn,
bdc_field USING 'P0022-ENDDA' '31129999',
bdc_field USING 'P0022-SLART' 'XX',
bdc_field USING 'P0022-INSTI' 'FH Irgendwo',
bdc_field USING 'P0022-SLABS' '50',
bdc_field USING 'P0022-EMARK' '1.7',
bdc_field USING 'P0022-SLAND' 'DE',
bdc_dynpro USING 'SAPMPAP4' '0100',
bdc_field USING 'BDC_OKCODE' '/EEBAC'.
CALL TRANSACTION 'PB10' USING bdcdata
MODE 'E'
MESSAGES INTO messtab.
Error in messtab
Edited by: Timo Ehl on Oct 24, 2011 9:05 AMHi Kevin,
Is it really FB01<b>L</b>? I cannot find it in my 46c system?
Anyway, you can control this message as follows. Go to SM30, enter V_T100C and 'Maintain'. Enter 'F5' for application area in the subsequent pop-up.
In the table control, see if message number 192 is already there. If it is there, then change the value under column 'BatchI' to 'I' and save. If it is not there, then enter a new record for 192.
Hope this helps,
Srinivas -
Is it possible to combine mappings?
For example, suppose you have two tables in a parent child relationship and you create a one-to-many mapping between them. Suppose further, that you have another pair of tables that you map the same way. Obviously, the two mappings can be used independently. However, what if, in some circumstances, the two parent tables are related? Do you have to construct another mapping of all four tables?
In my specific example, I was content to create and persist new entities using separate pieces of business logic. I now have a requirement to retrieve all instances of the data ie the joined data. It is easy to read all instances of each class, but this doesn't relate them.
I suspect I am going about this in the wrong way, but my system has a large number of tables and I want to be able to create simple mappings and the reuse them to create more complex mappings.
Could someone be so kind as to point me in the right direction.
Thanks
MikeDonald,
I don't think any of your ideas are remotely absurd. As you say lack of familiarity with a domain makes it difficult to offer targetted advice.
As you doubtless realise, the question is related to a general rather than a specific problem - the desire to be able to define classes and reuse them as class building blocks for more complex transactions.
The use of views is perfectly workable, but simply transforms the problem into one of maintaining views. I'm sure we'll use the idea in some situations.
The matching in memory is OK for single instances, but doing a bulk read without a join ends up being a series of individual reads, losing out on the power of the database.
Since this morning, I've been experimenting. I've created a new class based on one of the parent tables and created a 1:n mapping with its child and a 1:1 mapping with the class representing the other parent child pair. If this works, it isn't a bad "second best" and it is along the lines you were suggesting.
One question though if I may. When modelling a 1:n relationship, I put a 1:n mapped attribute in the parent class and a 1:1 mapped attribute in the child class. I've found that I have to delete the attribute in the child class that maps to the primary key of the parent - otherwise I have two mappings to the same attribute. Leaving it as unmapped causes problems later. Am I doing somnething wrong? It hasn't mattered until now, but is causing me problems with this example.
Thank you for your help.
Mike -
Please help, im so confused
im trying too make a till for a shop but im getting the error 'operator * cannot be applied to int,Price total += tempItemAmount * (tempItem.getItemPrice());'
private int printItemReceipt(ArrayList tempItems) {
// Clone the tempItems list so that it can be picked apart
ArrayList tempReceipt = (ArrayList)tempItems.clone();
* Print a list of the items in a receipt format (to be sold)
* This is done by searching through the list, when an object
* is found, a search for other objects of the same type is
* run, when one is found, the ammount of the object is increased
* then the instance is removed from the list until there are no more
// Hold the total item cost tally
int total = 0;
for(int i = 0; i < tempReceipt.size(); i++){
Item tempItem = (Item)tempReceipt.get( i );
int tempItemAmount = 0;
while(tempReceipt.contains(tempItem)){
tempItemAmount++;
tempReceipt.remove( tempItem );
System.out.println( "\n" + tempItemAmount + " x " + tempItem.getItemName() );
System.out.print(" $" + tempItem.getItemPrice() + "(x" + tempItemAmount + ")");
System.out.print(" $" + (tempItemAmount * (tempItem.getItemPrice())) );
total += tempItemAmount * (tempItem.getItemPrice()); <=== just here
System.out.println("\n\nItem total = $" + total);
System.out.println();
return total;
* null
* @param tempItems
private void checkout(ArrayList tempItems){
}and i dont know why or how to fix it any and all help is welcomedits a big bit of code (well for a newbie like me any way) but here it is
import java.io.*;
import java.util.ArrayList;
import java.io.Serializable;
import java.text.StringCharacterIterator;
import java.util.*;
* This is the main class - the program is run by java Shop
public class Shop implements Serializable {
public Shelves theShelves = new Shelves();
public Till theTill = new Till();
transient BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
int balance; //holds the value from getQuatity
* Using startUp an owner can add various goods to the system.
* We can then can add an item, set the price and set the stock level.
public void startUp() {
// Stores the user's menu choices
int choice = 0;
String tempChoice;
try{
do{
System.out.println("\nWelcome to the item menu. Do you wish to:");
System.out.println("1: Add a new item");
System.out.println("2: Set an item price");
System.out.println("3: Set an item stock level");
System.out.println("Esc: Back to Main Menu");
System.out.print("\nPlease chose an option: ");
tempChoice = buf.readLine();
// Check for an Esc symbol and return if found
if( tempChoice.charAt(0) == 27 ){
return;
}while(true);
// Convert the tempChoice string to a more managable integer
choice = Integer.parseInt( tempChoice );
switch(choice){
case 1:
// Create a new item which will be added to the shelves
createItem();
break;
case 2:
// Provide the user with a list of existing items to chose from, along with an index
System.out.println("\nPlease enter the number of the item you wish to change the price of...");
System.out.println( theShelves );
System.out.print("\nEnter number here: ");
// Call setItemPrice and pass the item number input from the user
setItemPrice( Integer.parseInt( buf.readLine() ) );
break;
case 3:
// Provide the user with a list of existing items to chose from, along with an index
System.out.println("\nPlease enter the number of the item you wish to change the stock level of...");
System.out.println( theShelves );
System.out.print("\nEnter number here: ");
// Call setItemPrice and pass the item number input from the user
setItemStockLevel( Integer.parseInt( buf.readLine() ) );
break;
default:
System.out.println("\nPlease enter a valid option");
break;
catch (IOException e){
System.out.println("\nThe till has suffered an IO exception "+e);
catch(NumberFormatException e){
System.out.println("\nPlease enter a number only");
* Using startTill, an owner can add the various
* monies to the till specifying the name, value
public void startTill(){
// Stores the user's menu choices
int choice = 0;
String tempChoice;
do{
System.out.println("\nWelcome to the monies menu. Do you wish to:");
System.out.println("1: Add a new money type");
System.out.println("2: Add more of an existing money");
System.out.println("3: Remove monies");
System.out.println("Esc: Back to Main Menu");
System.out.print("\nPlease chose an option: ");
tempChoice = buf.readLine();
// Check for an Esc symbol and return if found
if( tempChoice.charAt(0) == 27 ){
return;
// Convert the tempchoice string to a more managable integer
choice = Integer.parseInt(tempChoice);
switch(choice){
case 1:
createMoney();
break;
case 2:
setMoney(choice);
break;
case 3:
setMoney(choice);
break;
while(true);
* Using runTill, an owner can sell items.
* Customers put in their order, the system
* then tells her how much to charge.
public void runTill() {
// Stores the user's menu choices
int choice = 0;
String tempChoice;
// Stores the list off items to be sold
ArrayList tempItems = new ArrayList();
while(true){
try{
System.out.println("\nWelcome to the sales menu. Do you wish to:");
System.out.println("1: Enter name or number of item to be sold");
System.out.println("2: Show current Receipt");
System.out.println("3: Complete sale");
System.out.println("4: List all items");
System.out.println("Esc: Back to Main Menu");
System.out.print("\nPlease chose an option: ");
tempChoice = buf.readLine();
// Check for an Esc symbol and return if found
if( tempChoice.charAt(0) == 27){
return;
// Convert the tempChoice string to a more managable integer
choice = Integer.parseInt( tempChoice );
switch(choice){
case 1:
// Stores the temporary item name or number
String tempItemName;
int tempItemNumber = 0;
// Creates temporary storage for an item, presets to null
Item tempItem = null;
// Ask the user for the name of the item to be sold
System.out.print("\nPlease Enter the Name or Number of the item to sell: ");
tempItemName = buf.readLine();
// Attempt to parse an array index value (int) from the user input
// if a number format exception is caught the input must be a string
// so a different call the theList should be made to find the item
try{
if(tempItem == null){
tempItemNumber = Integer.parseInt( tempItemName );
catch (NumberFormatException e){
//bubble sort
finally{
if( tempItem == null ){
// Find the item by its indexed number
tempItem = theShelves.getItemByPosition( tempItemNumber );
// Ask the user for the number of the item(s) to be sold
System.out.print("\nPlease Enter how many " + tempItem.getItemName() + "(s) are to be sold: ");
int tempItemAmount = Integer.parseInt( buf.readLine() );
// For the number of items, add the item to the item ArrayList
for(int i = 0; i < tempItemAmount; i++){
tempItems.add( tempItem );
break;
case 2:
// Call printItemReceipt to print a receipt from the passed Item ArrayList
System.out.println("\nReceipt of current items being sold:");
printItemReceipt( tempItems );
break;
case 3:
// Pass the item list to checkout for calculation of money totals
checkout( tempItems );
break;
case 4:
// Print a list of all item names along with indexes
System.out.println( "\n" + theShelves );
break;
default:
System.out.println("\nPlease enter a valid option");
break;
catch (IOException e){
// Print an error message to handle the IO Exception
// (Error in receiving user input)
System.out.println("\nThe till has suffered an IO exception "+e);
catch(NumberFormatException e){
// Print an error message to handle the NumberformatException
// (User has entered a none int value)
System.out.println("\nPlease enter a number only");
* Using getChange, an owner can tell the systen how much of
* each denomination she has been given by the customer and
* the till tells her what to giveback.
public void getChange(){
* Using getBalance it tells the owner what is left in the
* till and how much money has been made during the day
public void getBalance(){
Monies tempMonies = new Monies();
balance = tempMonies.getQuantity(); //getQuantity returns a int value
* runMenu provides the main menu to the shop allowing a
* user to select their required operation
public void runMenu() {
// This is the main menu which runs the whole shop
// Stores the user's menu choices
int choice = 0;
String tempChoice;
while( true ){
try{
System.out.println("\nWelcome to the main shop menu. Do you wish to:");
System.out.println("1: Add / Edit items");
System.out.println("2: Add / Edit money types");
System.out.println("3: Sell Items");
System.out.println("Esc: Exit shop program");
System.out.print("\nPlease chose an option: ");
tempChoice = buf.readLine();
// Check for an Esc symbol and return if found
if( tempChoice.charAt(0) == 27 ){
return;
// Convert the tempChoice string to a more managable integer
choice = Integer.parseInt( tempChoice );
switch(choice){
case 1:
// Call startUp for adding and editing new items
startUp();
break;
case 2:
// Call startTill for adding and editing money types (coins¬es)
startTill();
break;
case 3:
// Call runTill for selling items
runTill();
break;
default:
System.out.println("\nPlease enter a valid option");
break;
catch (IOException e){
// Print an error message to handle the IO Exception
// (Error in receiving user input)
System.out.println("\nThe till has suffered an IO exception "+e);
catch(NumberFormatException e){
// Print an error message to handle the NumberformatException
// (User has entered a none int value)
System.out.println("\nPlease enter a number only");
* // LEAVE ALL THE CODE BELOW UNTOUCHED UNLESS YOU KNOW WHAT YOU ARE DOING
// DON'T TOUCH THIS - YOU HAVE BEEN WARNED!!!
// Open a file and write out object
* @param fullPathOfFile
* @exception IOException
public void writeToFile(String fullPathOfFile)throws IOException
// Lets get a handle on the file to write to
File myFile = new File (fullPathOfFile);
ObjectOutputStream myStream = new ObjectOutputStream(
new BufferedOutputStream(
new FileOutputStream(myFile)));
System.out.println("Writing to the file now....");
myStream.writeObject(this); // Write the object to file
myStream.close(); // Don't forget this!!
* Open the file and read in object
* DON'T TOUCH THIS - YOU HAVE BEEN WARNED!!!
* This needs to be static - an object cannot read in itself
* @return Shop
* @param fullPathOfFile
* @exception IOException
public static Shop readFromFile(String fullPathOfFile)throws IOException
// This will hold our new object
Shop theShopContents;
// Lets get a handle on the file to read in
File myFile = new File (fullPathOfFile);
if ((!myFile.isFile()) || (!myFile.canRead()))
// Let's leave
throw new IOException("Path is not valid ....");
ObjectInputStream myStream =
new ObjectInputStream(
new BufferedInputStream(
new FileInputStream(myFile)));
System.out.println("Reading from the file now....");
// Read the object from file - it needs to be cast
try
theShopContents = (Shop) myStream.readObject();
catch(ClassNotFoundException e)
throw new IOException("Objects of incorrect class");
catch(InvalidClassException e)
throw new IOException("Class definition changed");
myStream.close();
return theShopContents;
* @param args
public static void main(String[] args) {
// Don't touch any of this code
Shop betsy;
try {
betsy = Shop.readFromFile("./Betsy.data");
betsy.buf = new BufferedReader (new InputStreamReader(System.in));
catch (Exception e) {
// Something went wrong so start a new shop
betsy = new Shop();
betsy.runMenu();
try {
betsy.writeToFile("./Betsy.data");
catch (Exception e) {
System.out.println("Sorry but we just lost everything");
* Creates a new item, and adds it to the shelves
private void createItem() {
try{
// Ask the user for the name of the new item
System.out.print("Please enter the name of the item to be created: ");
// Create the new item with the name the user has given
Item tempItem = new Item(buf.readLine());
// Add the item to the shelves
theShelves.addItem(tempItem);
// Call the setItemPrice function
setItemPrice(tempItem);
// Call the setItemStockLevel function
setItemStockLevel(tempItem);
catch (ShelfExceptionFull e){
// Print an error message to handle the ShelfExceptionFull
// (No more room on the shelves to add new item)
System.out.println("\nThere is no more room to add an item to the shelves "+e);
// Return to the root menu
return;
catch (IOException e){
// Print an error message to handle the IO Exception
// (Error in receiving user input)
System.out.println("\nThe till has suffered an IO exception "+e);
* Changes the price of an item using the passed item object
* @param tempItem
private void setItemPrice(Item tempItem){
boolean done = false;
while( done != true ){
try{
// Ask for the input of the item price
System.out.print("Please Enter the price of the item: $");
// Set the item price
tempItem.setItemPrice(Integer.parseInt (buf.readLine()));
// Set the loop to finish
done = true;
catch (IOException e){
System.out.println("\nThe till has suffered an IO exception "+e);
catch(NumberFormatException e){
System.out.println("\nPlease enter a number only");
* Sets the stock level of an item using the passed item number to locate the object
* @param itemNumber
private void setItemStockLevel(int itemNumber){
Item tempItem = theShelves.getItemByPosition( itemNumber );
// Create 'done' to hold the condition of the following while loop
boolean done = false;
while(done != true){
try{
// Ask for the input of the item stock level
System.out.print("Please Enter the stock level of the item: ");
// Set the item stock level
tempItem.setQuantity( Integer.parseInt( buf.readLine() ) );
// Set the loop to finish
done = true;
catch (IOException e){
// Print an error message to handle the IO Exception
// (Error in receiving user input)
System.out.println("\nThe till has suffered an IO exception "+e);
catch(NumberFormatException e){
// Print an error message to handle the NumberformatException
// (User has entered a none int value)
System.out.println("\nPlease enter a number only");
* Sets the stock level of an item using the passed item object
* @param tempItem
private void setItemStockLevel(Item tempItem) {
// Create 'done' to hold the condition of the following while loop
boolean done = false;
while(done != true){
try{
// Ask for the input of the item stock level
System.out.print("Please Enter the stock level of the item: ");
// Set the item stock level
tempItem.setQuantity( Integer.parseInt( buf.readLine() ) );
// Set the loop to finnish
done = true;
catch (IOException e){
// Print an error message to handle the IO Exception
// (Error in receiving user input)
System.out.println("\nThe till has suffered an IO exception "+e);
catch( NumberFormatException e ){
// Print an error message to handle the NumberformatException
// (User has entered a none int value)
System.out.println("\nPlease enter a number only");
* Decrements the stock level of a passed item object
* @param tempItem
private void DecItemStockLevel(Item tempItem){
// Get the current item stock level and store locally
int tempQuantity = tempItem.getQuantity();
// Set the new item stock level to the current level - 1
tempItem.setQuantity( --tempQuantity );
* null
private void createMoney(){
Monies tempMonies = new Monies();
System.out.print("\nPlease enter the name of the coin/cash type you wish to create: ");
tempMonies.setCoinName(buf.readLine());
System.out.print("\nPlease enter the numerical value of the new money type: ");
tempMonies.setValue(Integer.parseInt(buf.readLine()));
private void setMoney(int quantity){
Monies tempMonies = theTill.getMoniesByPosition(quantity);
boolean done = false;
while(done != true){
try{
// Ask for the input of the till money
System.out.prinln("Please enter the amount of money in the till ");
// Set the till money
tempMonies.setQuantity(Integer.parseInt(buf.readLine()));
// Set the loop to finish
done = true;
catch (IOException e){
// Print an error message to handle the IO Exception
// (Error in receiving user input)
System.out.println("\nThe till has suffered an IO exception "+e);
catch(NumberFormatException e){
// Print an error message to handle the NumberformatException
// (User has entered a none int value)
System.out.println("\nPlease enter a number only");
* Prints a list of items from an ArrayList in receipt format
* (List must only contain type 'Item')
* @return int
* @param tempItems
private int printItemReceipt(ArrayList tempItems) {
// Clone the tempItems list so that it can be picked apart
ArrayList tempReceipt = (ArrayList)tempItems.clone();
* Print a list of the items in a receipt format (to be sold)
* This is done by searching through the list, when an object
* is found, a search for other objects of the same type is
* run, when one is found, the ammount of the object is increased
* then the instance is removed from the list until there are no more
// Hold the total item cost tally
int total = 0;
for(int i = 0; i < tempReceipt.size(); i++){
Item tempItem = (Item)tempReceipt.get( i );
int tempItemAmount = 0;
while(tempReceipt.contains(tempItem)){
tempItemAmount++;
tempReceipt.remove( tempItem );
System.out.println( "\n" + tempItemAmount + " x " + tempItem.getItemName() );
System.out.print(" $" + tempItem.getItemPrice() + "(x" + tempItemAmount + ")");
System.out.print(" $" + (tempItemAmount * (tempItem.getItemPrice())) );
total += tempItemAmount * (tempItem.getItemPrice());
System.out.println("\n\nItem total = $" + total);
System.out.println();
return total;
* null
* @param tempItems
private void checkout(ArrayList tempItems){ -
I was editing a Youtube video and I noticed my text layers I added to my footage wouldn't render out on video. Instead my video would freeze then start playing again. I tried to render out as a ProRes file and it still happened. Then I just wanted to render out the text and low and behold the screen was blank. I just switched recently from CS6 is there any way around this? It's a good thing I discovered this early because I still have my 30days to cancel.
I'm editing on a Macbook Pro Retina 15 inch with 2GB Nvidia Card and 16GB of RAM.
Thank you all in advanceIn addition to the oddities that Ann noted, the sequence is interlaced whereas the export settings are progressive. I have no particular reason to think that any of these weird little details would cause a problem, but it sure is a quirky set of properties.
I'd start by testing with a more normal scenario to see if the problem persists:
New project
New sequence, using a 1080 preset, such as AVCHD 1080p24.
Create a Universal Counting Leader and a title and add both to the timeline.
Export to the same YouTube preset.
If the encoded output from that sequence has the same problem, then it's time to collect info about your system: OS version, graphics card & driver, whether you've installed any codecs.
If the title survives the test, then start tweaking things in the direction of the problematic sequence, changing just one variable at a time--adding the odd 29.99 AVCHD clip, changing one sequence setting at a time, etc. Export after each change and see if the issue resurfaces.
Also worth testing:
try the various encoding paths: "in-process" by clicking Export in the Export Settings dialog, and via AME by clicking Queue.
In AME, encode one with the Import Sequences Natively setting enabled, then again with the option disabled. [Preferences>General]
Test with Renderer set to GPU Acceleration and with it set to Software Only [File>Project Settings>General]
Maybe you are looking for
-
Calling a stored procedure with the DI API in 6.5
Hi, Is it possible to do this? I have the following lines of code... sSQL = "EXEC sp_AgedDebtForCustomerStatement" oRecordset.DoQuery sSQL This procedure runs fine in SQL Query Analyzer and the query generator in B1. When I use it in my VB ap
-
IPhone 5 - black model paint problem
Dear apple community! I have iPhone 5 black model and edge color was chipped off after very carefull usage! If the paint chips this easy now what's my phone gonna look like in a years time after being in and out of my pocket, car keys, kids getting h
-
Outlook delete attachment files if use POP3
Hi every body, I have a problem with outlook. I send a mail with attachment using java mail api. Anyone get the mail correctly (gmail, outlook, outlook express or thunderbird) via SMTP. But if outlook try to get the mail via POP3, it deletes attachme
-
Why Do We Need Constructor With Arguments?
I understand that constructor is used to create instances. We can have constructors with 0 argument or with one/multiple arguments. Why do we need a contructor with arguments? What is the purpose of doing it? Thank you for your help.
-
Competitor - Strategy and counter strategy text fields in Web UI
Hi, I want to bring strategy & counter strategy text fields in the competitor screen of opportunity. Component: BT130I_OPPT View: BT130I_OPPT/CompetitorProdEF .The other standard fields strength and weakness are already visible in WEbUI. Also the t