Transient object to persistent
Hi all,
How can I make persistent a previously created transient object? I mean, is there any other way of making it persistent instead of executing method CREATE_PERSISTENT( attributes ) ??
Maybe something like:
MyTransientObject = Agent->Create_Transient( ... )
MyTransientObject->MakePersistent( )
Thanks in advance.
Hi Jorge,
what I was suggesting was to just call the create_persistent method with the attributes of the transient object except the business key. Then you will get a new business key for the persistent object. Then overwrite the reference to the transient object with the new persistent object reference.
Something like this.
MyTransientObject = Agent->Create_Transient( ... )
MyPersistentObject = Agent->Create_Persistent( ... ).
MyTransientObject ?= MyPersistentObject.
Cheers
Graham
Similar Messages
-
ABAP Object - Persistent Services - Transient Objects
Hi,
can anybody give an example of when I might want to use a transient object in the persistent services?
Cheers
AndrewHello Andrew,
Generally ABAP programs work with data and objects that are valid at
runtime. They are transient i.e. temporary and disappear when program ends.
To store this data permanently and independently of the program context,
it must be stored in the database. Persistent Services in ABAP Objects can be used to write the current values of objects defined as persistent to associated transparent tables. Later these values can be retrieved from the tables. In this way an object oriented database management system can be simulated.
Regards
Indrajit. -
How to verify whether the persistence unit objects are persistent or not?
How to verify whether the persistence unit objects are persistent or not?
I have successfully configure and deploy the Employees object as a persistence unit in Oracle Coherence according to the guide of Chapter 6 of Tutorial for Oracle Coherence 3.5.
Using the RunEmployeeExample script, I have got the right results. I can see that after the cache object is updated, the database table (Employees) is also updated accordingly. The following is the output:
2009-11-05 11:09:55.043/53.467 Oracle Coherence GE 3.5.2/463 <D5> (thread=Cluster, member=1): Member(Id=2, Timestamp=2009-11-05 11:09:54.867, Add
ress=192.168.8.80:8089, MachineId=24656, Location=process:1684, Role=OracleRunEmployeeExample) joined Cluster with senior member 1
2009-11-05 11:09:55.604/54.028 Oracle Coherence GE 3.5.2/463 <D5> (thread=Cluster, member=1): Member 2 joined Service Management with senior memb
er 1
2009-11-05 11:09:56.885/55.309 Oracle Coherence GE 3.5.2/463 <D5> (thread=Cluster, member=1): TcpRing: connecting to member 2 using TcpSocket{Sta
te=STATE_OPEN, Socket=Socket[addr=/192.168.8.80,port=8089,localport=4084]}
2009-11-05 11:09:57.847/56.281 Oracle Coherence GE 3.5.2/463 <D5> (thread=Cluster, member=1): Member 2 joined Service JpaDistributedCache with se
nior member 1
2009-11-05 11:09:57.917/56.341 Oracle Coherence GE 3.5.2/463 <D5> (thread=DistributedCache:JpaDistributedCache, member=1): Service JpaDistributed
Cache: sending ServiceConfigSync containing 258 entries to Member 2
2009-11-05 11:10:04.086/62.510 Oracle Coherence GE 3.5.2/463 <D5> (thread=DistributedCache:JpaDistributedCache, member=1): Deferring the distribu
tion due to 1 pending configuration updates
[EL Info]: 2009-11-05 11:10:14.36--ServerSession(2883071)--EclipseLink, version: Eclipse Persistence Services - 1.1.1.v20090430-r4097
[EL Info]: 2009-11-05 11:10:22.312--ServerSession(2883071)--file:/C:/JDeveloper/mywork/AppJPA/JPA/classes/-JPA login successful
2009-11-05 11:10:24.305/82.729 Oracle Coherence GE 3.5.2/463 <D5> (thread=DistributedCache:JpaDistributedCache, member=1): 3> Transferring 128 ou
t of 257 primary partitions to member 2 requesting 128
2009-11-05 11:10:25.697/84.121 Oracle Coherence GE 3.5.2/463 <D4> (thread=DistributedCache:JpaDistributedCache, member=1): 1> Transferring 129 ou
t of 129 partitions to a node-safe backup 1 at member 2 (under 129)
2009-11-05 11:10:25.857/84.281 Oracle Coherence GE 3.5.2/463 <D5> (thread=DistributedCache:JpaDistributedCache, member=1): Transferring 0KB of ba
ckup[1] for PartitionSet{128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151,
152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180,
181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238,
239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256} to member 2
2009-11-05 11:10:40.678/99.102 Oracle Coherence GE 3.5.2/463 <D5> (thread=Cluster, member=1): TcpRing: disconnected from member 2 due to a kill r
equest
2009-11-05 11:10:40.678/99.102 Oracle Coherence GE 3.5.2/463 <D5> (thread=Cluster, member=1): Member 2 left service Management with senior member
1
2009-11-05 11:10:40.678/99.102 Oracle Coherence GE 3.5.2/463 <D5> (thread=Cluster, member=1): Member 2 left service JpaDistributedCache with seni
or member 1
2009-11-05 11:10:40.708/99.132 Oracle Coherence GE 3.5.2/463 <D5> (thread=Cluster, member=1): Member(Id=2, Timestamp=2009-11-05 11:10:40.708, Add
ress=192.168.8.80:8089, MachineId=24656, Location=process:1684, Role=OracleRunEmployeeExample) left Cluster with senior member 1
2009-11-05 11:10:40.879/99.303 Oracle Coherence GE 3.5.2/463 <Info> (thread=DistributedCache:JpaDistributedCache, member=1): Restored from backup
128 partitions
2009-11-05 11:10:40.879/99.303 Oracle Coherence GE 3.5.2/463 <D4> (thread=DistributedCache:JpaDistributedCache, member=1): 0, 1, 2, 3, 4, 5, 6, 7
, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 4
4, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80
, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 11
3, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
2009-11-05 11:28:39.800/1178.224 Oracle Coherence GE 3.5.2/463 <D5> (thread=Cluster, member=1): Member(Id=2, Timestamp=2009-11-05 11:28:39.635, A
ddress=192.168.8.80:8089, MachineId=24656, Location=site:metsys.metex.com,machine:mw12,process:1752, Role=CoherenceConsole) joined Cluster with s
enior member 1
2009-11-05 11:28:40.231/1178.655 Oracle Coherence GE 3.5.2/463 <D5> (thread=Cluster, member=1): Member 2 joined Service Management with senior me
mber 1
2009-11-05 11:28:41.633/1180.057 Oracle Coherence GE 3.5.2/463 <D5> (thread=Cluster, member=1): TcpRing: connecting to member 2 using TcpSocket{S
tate=STATE_OPEN, Socket=Socket[addr=/192.168.8.80,port=8089,localport=4143]}
2009-11-05 11:30:01.658/1260.082 Oracle Coherence GE 3.5.2/463 <D5> (thread=Cluster, member=1): Member 2 joined Service DistributedCache with sen
ior member 2But I cannot verify if the persistence unit is still persistent.
Edited by: jetq on Nov 5, 2009 11:49 AMI start a Coherence Console in another Windows Command Prompt as the following:
D:\coherence\bin> coherence.cmd
** Starting storage disabled console **
java version "1.6.0_11"
Oracle Coherence Version 3.5.2/463
Grid Edition: Development mode
Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.
2009-11-05 11:57:22.167/9.734 Oracle Coherence GE 3.5.2/463 <D5> (thread=Cluster, member=n/a): Service Cluster joined th
e cluster with senior service member n/a
2009-11-05 11:57:22.197/9.764 Oracle Coherence GE 3.5.2/463 <Info> (thread=Cluster, member=n/a): Failed to satisfy the v
ariance: allowed=16, actual=20
2009-11-05 11:57:22.197/9.764 Oracle Coherence GE 3.5.2/463 <Info> (thread=Cluster, member=n/a): Increasing allowable va
riance to 17
2009-11-05 11:57:22.677/10.244 Oracle Coherence GE 3.5.2/463 <Info> (thread=Cluster, member=n/a): This Member(Id=3, Time
stamp=2009-11-05 11:57:22.392, Address=192.168.8.80:8089, MachineId=24656, Location=process:460, Role=CoherenceConsole,
Edition=Grid Edition, Mode=Development, CpuCount=1, SocketCount=1) joined cluster "cluster:0xD3FB" with senior Member(Id
=1, Timestamp=2009-11-05 11:09:09.738, Address=192.168.8.80:8088, MachineId=24656, Location=process:1816, Role=Coherence
Server, Edition=Grid Edition, Mode=Development, CpuCount=1, SocketCount=1)
2009-11-05 11:57:22.737/10.304 Oracle Coherence GE 3.5.2/463 <D5> (thread=Cluster, member=n/a): Member 1 joined Service
Management with senior member 1
2009-11-05 11:57:22.737/10.304 Oracle Coherence GE 3.5.2/463 <D5> (thread=Cluster, member=n/a): Member 1 joined Service
JpaDistributedCache with senior member 1
2009-11-05 11:57:23.108/10.675 Oracle Coherence GE 3.5.2/463 <D5> (thread=Invocation:Management, member=3): Service Mana
gement joined the cluster with senior service member 1
2009-11-05 11:57:23.759/11.326 Oracle Coherence GE 3.5.2/463 <D5> (thread=TcpRingListener, member=3): TcpRing: connectin
g to member 1 using TcpSocket{State=STATE_OPEN, Socket=Socket[addr=/192.168.8.80,port=4168,localport=8089]}
SafeCluster: Name=cluster:0xD3FB
Group{Address=224.3.5.2, Port=35463, TTL=4}The previous output shows that this Coherence console (the client side) has already joined the JPA server.
But the following output shows us that this console cannot access the Employees cache and cannot get the object entry. Why?
Map (?): cache Employees
2009-11-05 12:11:41.653/869.220 Oracle Coherence GE 3.5.2/463 <Info> (thread=main, member=3): Loaded cache configuration
from "jar:file:/D:/coherence/lib/coherence.jar!/coherence-cache-config.xml"
2009-11-05 12:11:43.055/870.622 Oracle Coherence GE 3.5.2/463 <D5> (thread=DistributedCache, member=3): Service Distribu
tedCache joined the cluster with senior service member 3
<distributed-scheme>
<!--
To use POF serialization for this partitioned service,
uncomment the following section
<serializer>
<class-
name>com.tangosol.io.pof.ConfigurablePofContext</class-
name>
</serializer>
-->
<scheme-name>example-distributed</scheme-name>
<service-name>DistributedCache</service-name>
<backing-map-scheme>
<local-scheme>
<scheme-ref>example-binary-backing-map</scheme-ref>
</local-scheme>
</backing-map-scheme>
<autostart>true</autostart>
</distributed-scheme>
Map (Employees): list
2009-11-05 12:11:48.402/875.969 Oracle Coherence GE 3.5.2/463 <Error> (thread=main, member=3):
java.lang.RuntimeException: Storage is not configured
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.DistributedCache$BinaryMap.onMissing
Storage(DistributedCache.CDB:9)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.DistributedCache$BinaryMap.ensureReq
uestTarget(DistributedCache.CDB:33)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.DistributedCache$BinaryMap.sendParti
tionedRequest(DistributedCache.CDB:31)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.DistributedCache$BinaryMap.size(Dist
ributedCache.CDB:13)
at com.tangosol.coherence.component.util.daemon.queueProcessor.service.grid.DistributedCache$BinaryMap$EntrySet.
size(DistributedCache.CDB:1)
at com.tangosol.util.ConverterCollections$ConverterEntrySet.size(ConverterCollections.java:2720)
at com.tangosol.coherence.component.application.console.Coherence.doList(Coherence.CDB:74)
at com.tangosol.coherence.component.application.console.Coherence.processCommand(Coherence.CDB:442)
at com.tangosol.coherence.component.application.console.Coherence.run(Coherence.CDB:39)
at com.tangosol.coherence.component.application.console.Coherence.main(Coherence.CDB:3)
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:597)
at com.tangosol.net.CacheFactory.main(CacheFactory.java:1400)Edited by: jetq on Nov 5, 2009 12:18 PM -
Transient Object in Appliaction Service
Hello *,
I have three Entity services:
one for product data from PLM -> external,
one for price data from SD -> external,
one for additional data -> local.
These three services I'd like to aggregate in one application service (PriceObject) which is remote enabled and accessible as a Web Service.
When my GUI or any other application wants to have a PriceObject, they call my PriceObjectService with material data (key) as input and get a complete PriceObject (including data from all three entity services).
Normally, if I add entity services as dependencies to my application service it can just return one of the entity services in operations tab.
So I think my question is:
How can I realize a transient object as application service which aggregates entity services and returns the aggregation?
Thanks in advance and best regards
JoschiHello Joachim,
Unfortunately there is no way to create a custom "Aggregate" output Data Structure which would hold these 3 Entity Services. You can create custom data structures, but there are no options for Entity types. You should be able to create an output Data Structure that holds 3 object references, but then the client would have to look up each entity by it's service interface.
Did you build Entity relationships for all 3 of these Entities? If so, then you can return one from your PriceObject and then the client can navigate to the other 2 through the generated getEntity() methods.
Maybe the best option would be to create a complex Data Structure which basically mimics the aggregate structure of your three Entities. In your PriceObject application service method, you would have to copy over the data from the 3 Entities into the new Transient data structure.
Regards,
Austin. -
How to set transient value to persistent attribute at commit in View Object
Hi
I'm using JDev11.1.1.2
I have a transient atttribute X in my View Object and a persistent attribute Y. I want the value of X to be assigned to Y before commit.
I saw that the entity has a method doDML that is used for this, but the problem is that this transient attribute is in my View Object, not entity object.
Any ideas?
ThanksHi
My transient attribute has a groovy expression assigned. This expression is calculated from other attributes in the view object.
It seems that the setter method of the transient attribute is not called when the value gets updated through groovy.
I used a transient attribute that duplicates my persistent attribute because groovy expression on transient attributes are recalculated, and the groovy expression on persistent attributes are not recalculated - they are used only for default values.
Any other ideas are appreciated!
Thanks -
Persistent and transient objects
New operator creates persistent objects in the case of fields of a class.
Local variables are put on the RAM stack.
Does that mean, that, in the case of local variables, new operator creates objects in RAM, or I have to use makeTransientByteArray?
Edited by: Dome313 on Apr 8, 2010 6:27 AMIf I get it right, in the case of local variables, new operator will place object reference to the stack, but the actual object content will be in EEPROM.
So should I create local variables using makeTransientXArray? For example
private byte[] deriveSessionKey(Cipher cipher, byte[] input)
byte[] output = JCSystem.makeTransientByteArray((short)16, JCSystem.CLEAR_ON_RESET);
byte[] ret = JCSystem.makeTransientByteArray((short)8, JCSystem.CLEAR_ON_RESET);
byte[] rand = JCSystem.makeTransientByteArray((short)6, JCSystem.CLEAR_ON_RESET);
Util.arrayCopy(input, (short)0, rand, (short)0, (short)6);
rand[2] = (byte) 0xF0;
cipher.doFinal(rand, (short)0, (short)6, output, (short)0);
Util.arrayCopy(output, (short)0, ret, (short)0, (short)8);
return ret;
}or should I define them as a class variables (because there may not be GC) and then use them in class methods?
Edited by: Dome313 on Apr 8, 2010 7:58 AM -
Use of transient objects via SIO. Is it possible?
Hi !
There are two applets. The first one contains a transient array of bytes (let denote it A)and a method, which can be called via Shareable Interface. This method uses array A. And when I call this method via SIO from the second applet, an error with SW = 6F 00 occurs.
Is it possible to use transient arrays via SIO? and what does happen whith them?
Java Card Specification says that "only the contents of the fields of the object (except for the length field) have a transient nature". So, they have to exist... but something goes wrong.It really runs with APDU buffer of usual Java Cards! Of course it works with the APDU buffer: it's a global array.
But SIM cards haven't such global array. Does it mean
that this scenario will not run there?Yes, it won't. As the APDU buffer is a global array (what implies that it is also a temporary JCRE entry point object), you're not able to store the reference in a class attribute or instance variable. So it's not useable for a Toolkit Applet which has been triggerd by an event.
A work around would be to pass each single primitive data unit to the Shareable Interface Object. But don't ask for performance ;o) -
Updating Transient objects in Kodo 2.5.5
I have a situation where I construct a JDO object in transient state in my
code ( for batch processing of data from a file into the database) by
calling the objects contructor and setting it's values. The row
representing this object may or may not exist in the database.
How do I make the object peristant ? If the row already exists, then I
must be able to update the row with the new values ( non-primary keys ).
If not, I should insert a new row.
There are no multi table relationships involved in this case. A JDO object
represents just one table.
We want to avoid the scheme which involves retrieve the object first and
then trying to update in a transaction.
AdarshTransaction t = kpm.currentTransaction();
try {
MyObject o = new MyObject(...)
t.begin();
Object id = ((PersistenceCapable)o).jdoNewObjectIdInstance();
((PersistenceCapable)o).jdoCopyKeyFieldsToObjectId(id);
try{
System.out.println(id);
Object trio = pm.getObjectById(id,true);
pm.deletePersistent(trio);
}catch(ObjectNotFoundException oe){
System.out.println("First time!");
pm.makePersistent(o);
t.commit();
}catch(...){ -
Transient Object with TopLink?
Can we create transient database objects with TopLink similar to the way we do with BC4J?
Eg: I can create a transient VO with BC4J with out a select query and add attributes to it. Can this be done with TopLink?Any Help.
-
When does an object become persistent?
I'm unclear about when I need to explicitly make an object persistent:
class PC1
Collection _items = new ArrayList();
class PC2
<class name="AssociationImpl">
<field name="_items">
<collection element-type="PC2"/>
</field>
</class>
PC1 pc1 = new PC1();
pm.makePersistent(pc1);
PC2 pc2 = new PC2();
pc1._items.add(pc2);
assert(JDOHelper.isPersistent(pc2)); // is pc2 persistent?
Which bit of the JDO spec makes this clear?
Thanks,
TomHi Marc,
I have a shop system comprised of two web applications where one is for
maintaining the shop and the other for using the shop. When I do changes
to the shop from the one webapp they do not show up in the second, unless
I call refresh. Also, I have to switch off the cache, it seems and do a
flush on the changed objects. There are some questions now:
a) when I call refresh, is the complete state reread regardless whether
there have been changes or not or does it know, when the state has not
changed in the DB ? it is a performance question, I guess.
b) can I use transactional reads to do the refresh automatically ?
c) I noticed that refresh does not do a deep refresh of all the objects
referenced by the one to be refreshed. Is there a way to do this or do I
have to go thru all the objects ?
I asked some questions some time ago in another thread, which might refer
to. I am sorry, if I am not clear enough.
Best regards
Wolfgang
Marc Prud'hommeaux wrote:
Wolfgang-
I take the question to mean that you are wondering how you can refresh
the state of a persistent instance to reflect changes in the data store.
If that is the case, then you can just call
PersistenceManager.refresh(ob) on the object, and the newer values will
be obtained.
If that doesn't help, can you clarify the question a little?
In article <cj7ris$mhr$[email protected]>, Wolfgang Kundrus wrote:
Do I have to use transactional reads for an object to get the changes done
by another web application ?
Thanks
Wolfgang
Marc Prud'hommeaux
SolarMetric Inc. -
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. -
Regarding persistent classes & objects
Hi all,
I am new to abap objects, please give me some simple links of persistent classes & object.
Let me know the difference between persistent classes & other simple classes..
I ensure you for points!
cheers.Hi,
Transient and persistent data
In principle, ABAP programs work with local program data, which resides in the programs internal session. This data lives only as long as its context that is, as long as its associated procedure (for local procedure data); its object (for attributes of classes); or its program (for global program data). This data is known as transient. Data that can be preserved beyond the runtime of the program is known as persistent. In SAP Systems, persistent data usually occurs as the content of database tables, but also as the content of files on application and presentation servers.
To work with persistent data, the system has to load it into transient data objects belonging to the ABAP program while that program is being executed. Then, after processing has been completed, it stores the data in a persistent form again. During this time, the content of the data exists twice: once in the ABAP program (transiently), and once in the appropriate storage medium (persistently). A typical process would be reading data from a database table using the SELECT statement into a transient work area; modifying the work area; and then updating the database table (using UPDATE). In such cases, the contents of transient and persistent data are different in the interim during this process.
Data in object-oriented programming
In an ideal object-oriented application, data occurs only as the attributes of objects (if we ignore the local data in methods for the time being). Objects are an aggregation of functions (in methods) and data (in attributes). The description of an object that is, the class occurs persistently as a piece of source code, but its attributes exist only as long as the object. However, an object in ABAP Objects is transient in principle. It exists in the internal program session only from the time it is generated (using CREATE OBJECT) until it is deleted by the Garbage Collector. Therefore, to work with persistent data in objects, you must program access to where those objects are stored within the methods of the class.
However, in completely object-oriented business application programming, then it is pointless simply to transfer the classical separation of data and functions to the methods that is, to work with objects, but use procedural programming within the objects themselves. Ideally you could save the encapsulation of data and functions persistently within the object instead. A program could then leave an object in a certain state and a second program could continue working on the object in that state. Classes of objects are already persistent anyway, but you need some way of saving the attributes of an object persistently and then make reference to the appropriate class. The Persistence Service allows you to do exactly that.
Persistent Classes
To use the Persistence Service for objects, the classes of these objects must be created as persistent classes in the Class Builder. The term persistent class does not imply that a class is persistent. (As a template for objects, every class is persistent). Rather, it means that the objects of that class and their state are managed by the Persistence Service. For example, the objects of these classes are instantiated in the ABAP program with a method of the Persistence Service, which ensures that the initialization is correct (not with the usual CREATE OBJECT statement). When the Class Builder creates a persistent class, it automatically generates an associated class, known as the class actor or class agent, whose methods manage the objects of persistent classes. As well as their identity, persistent classes can contain key attributes, which allow the Persistence Service to ensure that the content of each persistent object is unique.
Managed Objects
The objects of persistent classes are managed by the Persistence Service. This means, among other things, that these objects are instantiated with a method of the class actor, not with the CREATE OBJECT statement. These objects are known as managed objects. Objects managed by the Persistence Service can be either persistent or transient.
Persistent objects must be managed by the Persistence Service. The Persistence Service connects the object and the database.
Transient objects of persistent classes are also managed by the Persistence Service. For example, the Persistence Service ensures that the object is unique within a program (by checking its key attributes), but not for a connection to the database.
Plz refer to this link:
http://help.sap.com/saphelp_nw70/helpdata/en/f5/a3682ebc6911d4b2e80050dadfb92b/content.htm
Thanks,
Samantak.
Rewards points for useful answers. -
Hibernate: TransientObjectException
Hello all,
I'm trying to develop an application that persists all of its data to a Database using Hibernate. It works fine so far, but sometimes I stumble upon some strange Exceptions I don't really understand:
org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: net.snyke.tmm.vo.Account
at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:216)
at org.hibernate.type.EntityType.getIdentifier(EntityType.java:108)
at org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:221)
at org.hibernate.type.TypeFactory.findDirty(TypeFactory.java:476)
at org.hibernate.persister.entity.AbstractEntityPersister.findDirty(AbstractEntityPersister.java:2803)
at org.hibernate.event.def.DefaultFlushEntityEventListener.dirtyCheck(DefaultFlushEntityEventListener.java:467)
at org.hibernate.event.def.DefaultFlushEntityEventListener.isUpdateNecessary(DefaultFlushEntityEventListener.java:190)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:113)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:195)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:76)
at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:35)
at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:951)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:109)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:88)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1540)
at net.snyke.tmm.UserManager.loginAvailable(UserManager.java:45)
at net.snyke.tmm.TestUserManager.testLoginAvailable(TestUserManager.java:35)What I'm doing is the following:
UserAccount usr = new UserAccount("loginTest");
usr.persist();And then immeditely access it using an HQL query, which spits out the previous exception.
Just in case it matters, the persist method is inherited from my Base class:
public Long persist() throws HibernateException, SQLException {
HibernateSession.currentSession().saveOrUpdate(this);
return id;
}Any idea what I'm doing wrong? I thought Hibernate would sort out all the flushing and caching by itself, or am I missing something?
Regards,
SnykeLooks like you've got an instance of net.snyke.tmm.vo.Account that hasn't been written to the database yet.
Hibernate objects can be in one of several states. I'll quote from Dave Minter's "Pro Hibernate":
Transient objects exist in memory. Hibernate does not manage transient objects or persist changes.
Persistent objects exist in the database. Hibernate manages these.
Detatched objects have a representation in the database, but the application closes the HibernateSession that the object is associated with. The application will need to reattach the object by giving it another session and calling load, refresh, merge, update, or save methods on it.
% -
Does anyone know if ABAP Persistent Objects support cloning?
I can clone the object using a SYSTEM-CALL (though I'd rather not), however that would still mean breaking the rules to set the object key to a new value.
At the moment the only solution appears to be creating a new persistent or transient object via the agent and manually assigning the attributes.Thanks Uwe. I knew about the SYSTEM-CALL but in this case it does not help.
My problem is that the object key of a persistent object does not appear to be easily modified even from within the object. I want to clone the object and then modify the key to avoid insert collisions.
So far as I can see there is no simple way of modifying the business key of a persistent object.
For now I've implemented IF_OS_CLONE~CLONE in a public method of my persistent object, created a new persistent object and manually assigned the attributes. Unfortunately the code will have to be modified whenever a new attribute is added. -
PRO*C에서 OBJECT 예제 프로그램 (PERSISTENT OBJECT)
제품 : PRECOMPILERS
작성날짜 : 1998-11-25
PRO*C에서 object 예제 프로그램 (Persistent object)
==================================================
1. object type, object table를 생성하고, 데이타를 insert
drop table use_person
drop type person
create type person as object (
name varchar2(60),
address varchar2(200),
dob date,
age number(3,0)
create table use_person of person
insert into use_person values (
person('John Smith', '1 Somewhere', '10-jan-66', 32)
insert into use_person values (
person('Susan Jones', '2 Elsewhere', '16-may-72', 26)
2. OTT를 수행할 source를 생성한다.
(file명은 ojb_in.typ)
type person
3. OTT를 수행하여 person에 대응되는 c struct를 가지고 있는
obj.h를 생성한다.
ott intype=obj_in outtype=obj hfile=obj.h userid=scott/tiger
code=c
4. 예제 프로그램 <cache_obj.pc>
#include <stdio.h>
#include <string.h>
#include "obj.h"
/* VARCHAR 처리를 위한 macro. */
#define TERM(X) ( X.arr[X.len] = '\0' )
#define SLEN(X) ( X.len = strlen((char *)X.arr) )
EXEC SQL INCLUDE SQLCA;
EXEC SQL BEGIN DECLARE SECTION;
VARCHAR oracleid[20];
person person_ptr; / pointer로 선언됨에 주의*/
person_ind *person_ind_ptr;
person_ref *per_ref;
VARCHAR address[201];
VARCHAR birthday[21];
VARCHAR name[61];
int age;
EXEC SQL END DECLARE SECTION;
main()
char action_str[30];
EXEC SQL WHENEVER SQLERROR DO o_error(action_str);
/* Database에 connect */
strcpy( (char *)oracleid.arr, "scott/tiger" );
SLEN( oracleid );
strcpy( action_str, "connecting to d/b" );
EXEC SQL CONNECT :oracleid;
* client side object cache를 다루기 위해서는
* REF를 fetch 하여, 이를 이용하면 된다.
* REF를 할당하고, FETCH 하기
strcpy( action_str, "allocating ref");
EXEC SQL ALLOCATE :per_ref;
EXEC SQL DECLARE C1 CURSOR FOR
SELECT REF(p)
FROM USE_PERSON p
WHERE NAME = :name;
strcpy( (char *)name.arr, "John Smith" );
SLEN(name);
strcpy( action_str, "opening cursor" );
EXEC SQL OPEN C1;
strcpy( action_str, "fetching cursor" );
EXEC SQL FETCH C1 INTO :per_ref;
* cache에 있는 object에 대해 DEREF를 수행하고,
* FOR UPDATE문으로 해당 row에 대해 lock을 건다.
strcpy( action_str, "fetching object" );
EXEC SQL OBJECT DEREF :per_ref INTO :person_ptr:person_ind_ptr
FOR UPDATE;
/* address, dob 컬럼을 update하기. */
strcpy( action_str, "getting attributes" );
EXEC SQL OBJECT GET ADDRESS, DOB FROM :person_ptr:person_ind_ptr
INTO :address, :birthday;
TERM(address);
TERM(birthday);
printf("\nCurrent address is: %s", (char *)address.arr);
printf("\nCurrent birthday is: %s", (char *)birthday.arr);
strcat((char *)address.arr,", Nowhere Town");
SLEN(address);
strcpy((char *)birthday.arr,"12-jan-66");
SLEN(birthday);
strcpy( action_str, "setting attributes" );
EXEC SQL OBJECT SET ADDRESS, DOB OF :person_ptr:person_ind_ptr
TO :address, :birthday;
/* 변경 내용을 서버에 반영 */
strcpy( action_str, "marking object as updated" );
EXEC SQL OBJECT UPDATE :person_ptr;
strcpy( action_str, "writing update to database" );
EXEC SQL OBJECT FLUSH :person_ptr;
* object를 Release한다. 이때 unpin도 같이 수행된다.
* indicator인 경우에는 unpin 개념이 없다.
* object의 default DURATION은 transaction이기 때문에
* commit 이나 rollback을 수행하면 자동으로 unpin 된다.
* 만약 DURATION=SESSION으로 precompile을 했다면 오브젝트는
* 프로그램이 끝나거나, RELEASE문을 수행할때까지
* unpin되지 않는다.
strcpy( action_str, "unpinning object" );
EXEC SQL OBJECT RELEASE :person_ptr;
* Free the REF.
strcpy( action_str, "freeing ref" );
EXEC SQL OBJECT FREE :per_ref;
* commit하여 변경된 내용을 저장한다.
strcpy( action_str, "committing" );
EXEC SQL COMMIT;
* 다음은 object를 만들어 테이블에 insert 하는 방법이다.
* 즉, Cache에 object를 생성하여 이를 서버에 flush 시키는
* 방법이다. object를 ref로 선언하는 경우 그 object를
* return 하는데, persistent object로 선언하였기 때문에
* (즉, DB에 저장된object table) 이 REF는 DB 의 실제 row와
* 관련이 있다.
* REF 할당하기.
strcpy( action_str, "allocating ref");
EXEC SQL ALLOCATE :per_ref;
strcpy( action_str, "creating object" );
EXEC SQL OBJECT CREATE :person_ptr:person_ind_ptr
TABLE USE_PERSON
RETURNING REF INTO :per_ref;
* object indicator의 각 요소에 NOT NULL을 설정.
person_ind_ptr->atomic = OCIIND_NOTNULL;
* object와 indicator에 값을 설정하기
strcpy( (char *)name.arr, "Richard Mountjoy" );
SLEN(name);
strcpy( (char *)address.arr, "7 The Butts, Silchester" );
SLEN(address);
strcpy( (char *)birthday.arr, "16-nov-73" );
SLEN(birthday);
age = 24;
strcpy( action_str, "setting attributes" );
EXEC SQL OBJECT SET NAME, ADDRESS, DOB, AGE
OF :person_ptr:person_ind_ptr
TO :name, :address, :birthday, :age;
person_ind_ptr->NAME = OCI_IND_NOTNULL;
person_ind_ptr->ADDRESS = OCI_IND_NOTNULL;
person_ind_ptr->DOB = OCI_IND_NOTNULL;
person_ind_ptr->AGE = OCI_IND_NOTNULL;
* insert하기 위해 db에 object를 Flush하기
strcpy( action_str, "writing object to database" );
EXEC SQL OBJECT FLUSH :person_ptr;
strcpy( action_str, "unpinning object" );
EXEC SQL OBJECT RELEASE :person_ptr;
strcpy( action_str, "commiting" );
EXEC SQL COMMIT;
* REF는 실제 메모리가 할당되는 것이기 때문에, commit
* 된다 하더라도 메모리가 free되지 않는다. (DURATION이
* transacetion이라고 하더라도)
* object를 return한 REF는 DB에 저장되어 있는 object가
* 유용한지를 보여주는 용도로 사용할 수 있다.
* 어떤 값이 object에 copy되어 return되는 지는 version
* precompile option에 의해 결정된다.
* RECENT (default) : 현재 transaction에서 fetch했다면
* cache로부터 object를 return 하고,
* 아닌 경우는 db로 부터fetch를 하게
* 된다.
* ANY : 원래 어떤 값을 fetch했는 지에 관계없이 cache에
* 있는 값을 return 의미
* LATEST : DB로 부터 refetch
* 이 sample에서는 object를 release한 상황에서, db로 부터
* fetch했음을 보이기 위해 VERSION을 LATEST로 설정했다.
EXEC ORACLE OPTION (VERSION=LATEST);
strcpy( action_str, "fetching object" );
EXEC SQL OBJECT DEREF :per_ref INTO :person_ptr:person_ind_ptr;
* 초기화를 하면 indicator를 check할 필요가 없다.
name.len = 0;
address.len = 0;
birthday.len = 0;
age = -1;
strcpy( action_str, "getting attributes" );
EXEC SQL OBJECT GET NAME, ADDRESS, DOB, AGE
FROM :person_ptr:person_ind_ptr
INTO :name, :address, :birthday, :age;
printf("\n\nAttributes of newly created object are:");
TERM(name);
TERM(address);
TERM(birthday);
printf("\nName: %s", name.arr);
printf("\nAddress: %s", address.arr);
printf("\nBirthday: %s", birthday.arr);
printf("\nAge: %d", age);
* Clear up.
strcpy( action_str, "unpinning object" );
EXEC SQL OBJECT RELEASE :person_ptr;
strcpy( action_str, "freeing ref" );
EXEC SQL OBJECT FREE :per_ref;
EXEC SQL WHENEVER SQLERROR CONTINUE;
EXEC SQL ROLLBACK WORK RELEASE;
printf("\n");
int o_error( action_str )
char *action_str;
int i;
char error_str[150];
EXEC SQL WHENEVER SQLERROR CONTINUE;
for ( i = 0; i < sqlca.sqlerrm.sqlerrml; i++ )
error_str[i] = sqlca.sqlerrm.sqlerrmc;
error_str[i] = '\0';
printf( "\nFailed with following Oracle error while %s:\n\n%s",
action_str, error_str );
EXEC SQL ROLLBACK WORK RELEASE;
exit(1);
5. 프로그램 수행 결과
Current address is: 1 Somewhere
Current birthday is: 10-JAN-66
Attributes of newly created object are:
Name: Richard Mountjoy
Address: 7 The Butts, Silchester
Birthday: 16-NOV-73
Age: 24Thanks so much, Bob.
My printer requires that I use the PDF/X-1a:2001 standard for PDF export, which means that it must be Acrobat 4 or later compatibility.
Also: I don't see how to NOT flatten, when exporting PDF for print; the options for flattening are "low resolution," "medium resolution," or "high resolution"—but there is not an option to NOT flatten. Do you know a work-around for this?
Maybe you are looking for
-
What can I expect with 4.1
I want to build a fast computer - i7 with 12 gig of ram... fast drives...etc. I will shoot HMC150 AVCHD and transcode to NeoScene. I'm wondering about rendering... Will I be able to add a few filters such as Color Balance, Picture in Picture, Title w
-
In iBooks can I write side comments
Is there an app that works with iBooks to write in comments un the margins.
-
Hi Team, I have a requirement where I am suppose to display an IFrame in my jsp. How to keep a check if the IFrame src URL (another application) is up or not? If the server is down, I am getting 404 / IBM WAS error message page. I want to keep a chec
-
Why is my wi fi greyed out?
why is my wifi greyed out on my ipod touch? i have tried system restore and reset settings. nothing seems to be working.
-
I am getting below error...Any body can let me know what's the prob in timestamp.. I am using Oracle 9i. alter table jay add(td timestamp); alter table jay add(td timestamp) ERROR at line 1: ORA-00902: invalid datatype