Updating non-persistent fields in an Entity Object
Hi,
I wanted to add a non-persistent field to an Entity Object to use as a temporary aggregate field for a detail entity. It appears that storing data in the field makes it look like the master entity has been updated even though the value cannot be saved in the data base. Is this the way it is supposed to work?
I was trying to avoid putting invisible controls in the UI or creating "global" variables.
Thanks,
Peter
This can be done with programmatic VOs: http://download.oracle.com/docs/cd/E15523_01/web.1111/b31974/bcadvvo.htm#sm0341
Sample: http://blogs.oracle.com/smuenchadf/examples/#132
You can also opt to do this with a simple Java class and a data control based on it.
For example: http://blogs.oracle.com/shay/2009/07/java_class_data_control_and_ad.html
Similar Messages
-
Need to cache non-persistent field value
Is it possible to have a non-persistent field in PC class which value will be updated by app, stored in DataCache and then can be used when PC instance will be taken from DataCache next time?
I tried to map my field as persistence-modifier="transactional" or "none". I do see in my log that the object is taken from cache, but that transient field value is always null after object retreival.
Thanks, Denis.Thanks for the hint, Abe.
I got what I need via custom filed mapping. If anyone interested:
public class CacheFieldMapping extends ColumnFieldMapping {
public CacheFieldMapping(FieldMetaData meta) {
super(meta);
public String getMappingType() {
return getClass().getName();
protected int getJDBCType() {
return Types.OTHER;
public boolean map() {
return true;
public void fromMappingInfo(MappingInfo info, boolean adapt) {
// do nothing...
public void toMappingInfo(MappingInfo info) {
// do nothing...
public void refSchemaComponents() {
// do nothing...
public int select(Select sel, KodoStateManager sm, JDBCStoreManager store,
JDBCFetchConfiguration fetch, int eagerMode) {
return -1;
public void load(KodoStateManager sm, JDBCStoreManager store,
JDBCFetchConfiguration fetch, Result res) throws SQLException {
// do nothing...
public void load(KodoStateManager sm, JDBCStoreManager store,
JDBCFetchConfiguration fetch) throws SQLException {
sm.storeObject(getIndex(), null);
public Object loadProjection(JDBCStoreManager store,
JDBCFetchConfiguration fetch, Result res, Joins joins) throws SQLException
return null;
public Boolean isCustomInsert(KodoStateManager sm) {
return Boolean.TRUE;
public Boolean isCustomUpdate(KodoStateManager sm) {
return Boolean.TRUE;
protected void update(KodoStateManager sm, Row row) throws SQLException {
// do nothing...
"Abe White" <[email protected]> wrote in message
news:[email protected]..
No, this is not possible. The data cache acts exactly like the
database, only storing persistent values. -
Hi,
I would like to use toplink with objects that contains both persistent and non-persistent fields (unmapped). When I insert such an object to the database using unit-of-work, and then try to query toplink for that same object elsewhere in my program I only get the persistent fields. I've tried using checkCacheThanDatabase() which resolved the problem but this method is only available for ReadObjectQuery not for ReadAllQuery (the javadoc is not consistent with the code).
My questions:
1. For ReadObjectQuery, can I trust the cache to always have my object, or is there a risk that the cache will drop it?
2. What to do with ReadAllQuery?
3. Any other approach that can work?You can make non-persistent attributes remain with the object in a unit of work through using a clone policy and using the postMerge event.
Your class needs to implement Cloneable and in the descriptor use clone-copy-policy. This will ensure that when a cached object is registered into the unit of work the non-persistent attributes will be maintained.
When the unit of work merges a transactional object into the session cache you need to make sure you copy the non-persistent attributes from the clone to the cached object. You can do this through a DescriptorEventListener and the postMerge event.
Example:
postMerge(DescriptorEvent event) {
String tempProperty = ((MyClass) event.getObject()).getProperty();
((MyClass) event.getOringalObject()).setProperty(tempProperty);
Note that since the attribute is non-persistent it will not be guaranteed to persist indefinitely. The non-persistent attributes duration will be dependant on your caching policy, if it gets dropped from the cache, a new instance will be built from the database the next time it is accessed.
The checkCacheThanDatabase checkCacheOnly properties should not have any effect on what you get from the cache. Reads that access the database will still maintain object identity with the cache, and you should get back the correct object. -
Non persisted fields in entity class
Is it possible to declare a field of an entity class such that it does not get persisted?
Yes, use the JPA @Transient annotation (or transient field attribute).
-- James : http://www.eclipselink.org -
Best practice for linking fields from multiple entity objects
I am currently transitioning from PHP to ADF. I'm looking for the best practice for linking data from multiple entity objects.
Example:
EO 'REQUESTS' has fields: req_id, name, dt, his_stat_id, her_stat_id
EO 'STATUSES' has fields: stat_id, short_txt_descr
'REQUESTS' is linked to EO 'STATUSES' on: STATUSES.stat_id = REQUESTS.his_status_id
'REQUESTS' is also linked to EO 'STATUSES' on: STATUSES.stat_id = REQUESTS.her_status_id
REQUESTS.his_status_id is independent of REQUESTS.her_status_id
When I create a VO for REQUESTS, I want to display: REQUESTS.name, REQUESTS.dt, STATUSES.short_txt_descr (for his_stat_id), STATUS.short_txt_descr (for her_stat_id)
What is the best practice for accomplishing this? It appears I could do it a few different ways:
1. Create the REQUESTS VO with a LOV for his_stat_id and her_stat_id
2. Create the REQUESTS VO with the join to STATUSES performed within the query for the VO. This would require joining on the STATUSES EO twice (his_stat_id, her_stat_id)
3. I just started reading about View Links - would that somehow do what I'm looking for?
I also need to be able to update his_status_id and her_status_id through the by selecting a STATUSES.short_txt_descr from a dropdown.
Any suggestions on how to approach such a stupidly simple task?
Using jDeveloper 11.1.2.2.0 if that makes a difference in the solution.
Thanks ahead of time,
CJCJ,
I vote for solution 1 as it's just your use case. As you said you what to update the his_status_id and her_status_id through the by selecting a STATUSES.short_txt_descr by a drop down. This is exactly the LOV solution.
ViewLinks are used fro master detail navigation (which you don't do here) and Joining the data make it difficult to update (and you still need a LOV for the drop down box.
Timo -
Update non-editable field Start date which is calculated from other context
I had created some custom date fields(model, bol entity) in component ICCMP_BTSHEAD. We are calculating Start date based on the new input value into receiving date in the other context node.
so, for this i get the value on controller class(_IMPL). and pass the same value in the GET method of Start date.
But, Problem is Start date is the non-editable field so SET method will not be trigger as expected. so the same i used the DO_PREPARE_OUTPUT method but it's called and update the value when we press the enter. IF directly we click on the "SAVE" button then it' trigger but value is not updating in the database.
Please, find the below piece of code for the same. can u please anybody help me that how can i achieve this requirement.
DATA: l_recieve_date TYPE crmt_date_timestamp_from,
lr_current TYPE REF TO cl_bsp_wd_mixed_node,
lr_col TYPE REF TO cl_bsp_wd_collection_wrapper.
DATA: lv_date TYPE d,
lv_time TYPE t,
lv_date_temp TYPE sydatum.
IF iv_first_time EQ abap_false. "avoid for first tile load
Read the value of btreceivedate-TIMESTAMP_FROM.
lr_col = me->ztyped_context->btreceivedate->get_collection_wrapper( ).
IF lr_col IS BOUND.
lr_current ?= lr_col->get_current( ).
IF lr_current IS BOUND.
lr_current->if_bol_bo_property_access~get_property_as_value( EXPORTING iv_attr_name = 'TIMESTAMP_FROM'
IMPORTING ev_result = l_recieve_date ).
ENDIF.
ENDIF.
IF l_recieve_date IS NOT INITIAL.
CONVERT TIME STAMP l_recieve_date TIME ZONE sy-zonlo
INTO DATE lv_date TIME lv_time.
Check day is working day - if not, correct to previous working day
IF lv_date IS NOT INITIAL.
lv_date_temp = lv_date.
CALL FUNCTION 'DATE_CONVERT_TO_FACTORYDATE'
EXPORTING
correct_option = '-'
date = lv_date
factory_calendar_id = 'GB'
IMPORTING
date = lv_date_temp
EXCEPTIONS
date_after_range = 1
date_before_range = 2.
IF sy-subrc IS INITIAL.
lv_date = lv_date_temp.
ENDIF.
ENDIF.
CONVERT DATE lv_date TIME lv_time
INTO TIME STAMP l_recieve_date TIME ZONE sy-zonlo.
ENDIF.
lr_col = me->ztyped_context->btstart->get_collection_wrapper( ).
IF lr_col IS BOUND.
lr_current ?= lr_col->get_current( ).
IF lr_current IS BOUND.
lr_current->if_bol_bo_property_access~set_property(
iv_attr_name = 'APPT_TYPE' "#EC NOTEXT
iv_value = 'ZSTWTIME0001' ).
lr_current->if_bol_bo_property_access~set_property(
iv_attr_name = 'TIMESTAMP_FROM' "#EC NOTEXT
iv_value = l_recieve_date ).
ENDIF.
ENDIF.
ENDIF.
could you please help me?Hi,
Thanks for your reply,
yes, i checked the same thing also. But DO_HANDLE_DATA is called before the SET method of receiving date and in that case we are getting the old value in DO_HANDLE _DATA and source and Target fields both are not updating.
I checked, if, i'll change the input field then set method of input field and then EH_ON_SAVE is called directly.
i think, if i'll do the same modification in the EH_ON_SAVE method as i did in the DO_PREPARE_OUTPUT then it can be updated but i don't want to change the EH_ON_SAVE at this moment.
is there any other way to update the START DATE(Display mode in the screen) which is calculate from the other context node field receiving date. -
Specifying autoincrement on a field in an entity object declaratively
Hi,
I have a master-detail window where the detail entity has a composite key made up of m_id and d_id where m_id is a foreign key to the master table and d_id is the unique key to the detail table.
I have defined the detail entity object and checked the box for m_id and d_id as a primary key. When I create a new detail object using the create button that is available from the data control panel for the detail's view object it populates the m_id based on the currently selected master object. However since d_id needs to be populated as well.
Any ideas how I can do this declaratively in then entity object definition?
Cheers,
SThis can be done with programmatic VOs: http://download.oracle.com/docs/cd/E15523_01/web.1111/b31974/bcadvvo.htm#sm0341
Sample: http://blogs.oracle.com/smuenchadf/examples/#132
You can also opt to do this with a simple Java class and a data control based on it.
For example: http://blogs.oracle.com/shay/2009/07/java_class_data_control_and_ad.html -
Hi,
We have a need for a kodo-enhanced object to have a member field that
should NOT be persisted in the database.
I searched the docs several times but could not find the metadata to
specify this option. Any help would be greatly appreciated.
JohnWe have a need for a kodo-enhanced object to have a member field that
should NOT be persisted in the database.<field name="foo" persistence-modifier="none"/>
or make the field transient and it won't be persistent by default. -
Mass update to FILENAME field in S_DATASET authorization object
We are migrating to a new fileserver with a new hostname, and so I've been asked to update about 1900 instances of the S_DATASET authorization object for the new FILENAME value. I'd like to do this programmatically if possible.
What I've learned so far is that I need to update the value in table USR12, but the value is encoded. When I look at the table in SE16, I do not see the encoded value field. The value does show in UST12, but I'm told this is an unreliable table.
So I'd like to know..
1. How can I look at the value if not in SE16?
2. Is there an API I can use to encode/decode the value? If not, where is the specification on how to build it?
If this is better addressed in a different forum, which one should I try next?
Thanks,
DanHi there,
Okay I started a few tests and made a bit of progress, but am running into the problem that if I don't check the authority first using the FM and want to test what happens when the user is not authorized, then the bugger dumps (as expected and mentioned in the note)...
But the behaviour as you have described:
>
> Path Saveflag Fs_noread Fs_nowrite Fs_Brgru
> =============================================================
> * X X DUMY
> /temp/FI/.. X X DUMY
> /temp/FI X FIFI
>
... is correct, and I found something interesting in the F1 on the spth-path field which explains this.
> Caution:
> - If you enter paths generically in the table SPTH, the most precise specification counts.
> - If you select the no-read or no-write fields in the table SPTH, this overrides the authorization group.
So, the DUMY is not needed as the check does not use it in those cases, and "/temp/FI/.." is anyway more specific than "*" so the system would have used it for DUMY anyway. But that is irrelevant... because if the begru field is empty in the FM, then the check is not performed.
So, the only check which is effective to protect the path, is:
Path Saveflag Fs_noread Fs_nowrite Fs_Brgru
=============================================================
/temp/FI X FIFI
... and the "fs_noread" and "fs_nowrite" flags should be understood as "no protectable authority to read" and "no protectable authority to write" and not the activity field which the authority is being checked against. This is coming from the S_DATASET check (which is already known at that time to the function module).
Using these flags, you can leave the entries in the table without having to delete them if you want to turn them off and on temporarily. Perhaps an "active / inactive" switch would have been clearer...
form CHECK_PERMISSION using ISPTH_HEAD type SPTH
MODE type CLIKE
SUBRC type SY-SUBRC.
data: ACTIVITY like AUTHB-ACTVT.
SUBRC = 0.
case MODE.
when 'R'.
ACTIVITY = '03'.
when 'W'.
ACTIVITY = '02'.
when 'D'.
ACTIVITY = '02'.
endcase.
if ISPTH_HEAD-FS_BRGRU <> SPACE. "Here it is... for BEGRU checks there must be a value...
authority-check object 'S_PATH'
id 'FS_BRGRU' field ISPTH_HEAD-FS_BRGRU
id 'ACTVT' field ACTIVITY.
if SY-SUBRC <> 0.
SUBRC = 3.
endif.
endif.
endform.
Cheers,
Julius -
Updating non alphabatic field in a table
Hi,
1) I am using Release 10.2.0.1.0
2) I have a table with phone number field which has some data issues..... the data i get is like
with data_Set as
(select '1-212-344-3453 (cell)' phone_no from dual union all
select 'pager 212-221-2211' from dual
) select * from data_setI want to update this column so that appropriate phone number gets updated to the table.
any suggestions?
ThanksHi,
This is a great example of the problems you can run into with poor database design. In this case you have overloaded the phone number field to also include the phone type. You should have split this data across two fields, one for the phone number and one for the phone number type. This would make it much easier to search for phone numbers or phone number types as well as make validaion of the phone number type much easier.
Also, you shouldn't store the dashes (-) with the numbers. These can be inserted on presentation with the use format strings. The actual format string you would use for each type of phone number could be stored in the phone number type lookup table.
Regards
Andre -
How do I make a view object containing two entity objects updatable?
I have a view object that contains attributes from two entity objects. The query looks like this
SELECT AplCfgPartyEO.ID,
AplCfgPartyEO.ID_HRM_BRW_JOB,
HrmBrwJobEO.CREATED_BY,
HrmBrwJobEO.CREATION_DATE,
HrmBrwJobEO.ID AS ID1,
HrmBrwJobEO.ID_HRM_BAS_JOB_TYPE,
HrmBrwJobEO.JOB_NO,
HrmBrwJobEO.MODIFIED_BY,
HrmBrwJobEO.MODIFY_DATE,
HrmBrwJobEO.ORIGIN,
HrmBrwJobEO.PICTURE
FROM APL_CFG_PARTY AplCfgPartyEO, HRM_BRW_JOB HrmBrwJobEO
WHERE AplCfgPartyEO.ID_HRM_BRW_JOB = HrmBrwJobEO.ID
My problem is that I am only allowed to update the attributes from the AplCfgPartyEO entity object while the attributes from the HrmBrwJobEO entity object become read only. I want to be able to update all of the attributes how do I do that?If someone will read this later I can inform them that I am using Studio Edition Version 11.1.1.0.2 at the moment. Thanks Chris, your answer solved my problem but I was a little surprised though that it wasn´t updatable by default.
-
Marking a field as non-persistent?
Hi folks,
We've been building up a distributed data store that has a BDB at each leaf node. There are a few layers that our objects go through, and up until now we've been able to use our Entity objects directly throughout the code. They get serialized by RMI and make their way to our BDB nodes and get persisted by the DPL.
But now we have a situation where we have a field that we want serialized (non-transient) so that it makes its way all the way through our system, but then not persistent when it reaches the DPL. (We also have a search index at each leaf, and this bit of data includes some instructions for the search engine.)
The best solution (from my perspective!) would be simply to have an @NonPersistent annotation to make the DPL ignore a particular field. Lacking that, I came up with a couple options, neither of which I like. First, I could add a wrapper object that isn't an Entity class that contains my non-persistent data. I don't really like this idea, but it could work (makes all my objects a little larger and they get serialized a LOT). Second, I could modify readObject and writeObject to manually throw in the transient fields that I wanted to keep around. I don't really like that either (for different reasons), but it also could work.
Any other thoughts? Is there anything I'm missing that would allow me to do this easily?
Thanks!
JeffHi Jeff,
I think the addition of @NonPersistent is a reasonable request and probably the only good solution. One of the primary goals of the DPL is to be able to persist objects that are used in other ways -- RMI is a good example. In other words, the DPL intends to be a pure POJO persistence solution. However, we didn't consider the case of a field that is persistent with respect to RMI but not the DPL, or vice-versa. So I think solving this is important.
Let us spend some time on that and we'll see if we can get this into a 3.3 dot release. This is a fairly simply addition, but we'll need to also consider the reverse situation -- a field that is persistent WRT the DPL but not RMI. In other words, we may need both @Persistent and @NonPersistent to apply to a field to override the default rules. And we'll need to encapsulate this information in the EntityModel abstraction so that it can be used without annotations.
In the meantime, I suggest using one of the workarounds you mentioned, or perhaps even modifying the DPL source code in a way that works for you, temporarily.. If you choose the latter, note that there is only one place where field persistence is determined, which is in the getInstanceFields method of this class:
src/com/sleepycat/persist/impl/FieldInfo.java
See the call to Modifier.isTransient.
--mark -
Single Persistent instance of a Object, Many non persistant. Same Identity on persist
I have a persistent bean class with two Strings as member fields. (example
below)
I have many other classes that use it a part of they're member fields.
I need to have only one persistant version of it (One row, to many Rows in
different tables). But can have many non persistant versions. I can't
control the creation of the non persistant objects.
i.e.
On persist, How can I configuration JDO to detect that it's the same as an
object already in the database and use that instead?
example:
// Example class One
package foo;
public class One(){
public String var1;
public String var2;
public String getVar1(){
return this.var1;
public void setVar1(String var1Set){
this.var1 = var1Set
public String getVar2(){
return this.var2;
public void setVar2(String var2Set){
this.var2 = var2Set
/// one.jdo
<?xml version="1.0"?>
<jdo>
<package name="foo">
<class name="One"/>
</package>
</jdo>
///Example Scenario
One oneObject = new One();
oneObject.setVar1("Value1");
oneObject.setVar2("Value2");
pm.makePersistent(oneObject); // one row in database
/// Some time later, in a different thread, or since JVM shutdown and
restart
One oneObject = new One();
oneObject.setVar1("Value1");
oneObject.setVar2("Value2");
pm.makePersistent(oneObject); // one row in database, instead of two.You cannot. You should either find the object by query or retrieve it
using application identity.
Graham Cruickshanks wrote:
I have a persistent bean class with two Strings as member fields. (example
below)
I have many other classes that use it a part of they're member fields.
I need to have only one persistant version of it (One row, to many Rows in
different tables). But can have many non persistant versions. I can't
control the creation of the non persistant objects.
i.e.
On persist, How can I configuration JDO to detect that it's the same as an
object already in the database and use that instead?
example:
// Example class One
package foo;
public class One(){
public String var1;
public String var2;
public String getVar1(){
return this.var1;
public void setVar1(String var1Set){
this.var1 = var1Set
public String getVar2(){
return this.var2;
public void setVar2(String var2Set){
this.var2 = var2Set
/// one.jdo
<?xml version="1.0"?>
<jdo>
<package name="foo">
<class name="One"/>
</package>
</jdo>
///Example Scenario
One oneObject = new One();
oneObject.setVar1("Value1");
oneObject.setVar2("Value2");
pm.makePersistent(oneObject); // one row in database
/// Some time later, in a different thread, or since JVM shutdown and
restart
One oneObject = new One();
oneObject.setVar1("Value1");
oneObject.setVar2("Value2");
pm.makePersistent(oneObject); // one row in database, instead of two.
Steve Kim
[email protected]
SolarMetric Inc.
http://www.solarmetric.com -
Problem creating non-persistent Child Objects
I have the need to create a non persistable child object in the
jdoPreStore of a parent object. I then perform some tests on the parent
to determine if the child object needs to be persisted or not. If I leave
the child non persistent it still writes to the database.
I was performing the follwoing piece of code
Class Parent {
// The relationship is a 0 to many
public Child createChild() {
Child child = .....//create non persistent object
child.setParent(this);
getChild().add(child);
It appears that if I remove the getChild().add(child). It does not
persist (as desired).
Is this correct behaviour?? I dont think that it should be, but if it is
then I have a further problem.
If that child object inherits from another object and you remove the
getChild().add(child) kodo outputs an invalid object to the database. It
doesnt insert a row to the child table. But it inserts a row to the
childs inherited object table. This is now an invalid object and will
fail upon loading.
Any help on this would be appreciated.
Thanks
Luke.JDO has something called persistence by reachability. This means that
objects do not have to explicitly be marked as to be persistent as JDO
will traverse the object graph to ensure that all nodes are persistent.
I think you are seeing this behavior combined with another side
behavior: Kodo requires that both sides of a relation be set.
Basically, keep your objects in synch (set both sides of the relation).
And if you want to hold onto a reference to non-persistent object
before you decide what to do with it, add a transient field or a field
marked "persistence-modifier="none"" in your metadata and then process
those transient fields in jdoPreStore ().
i.e.
if (//businessLogic is true)
persistentField = transientField;
Luke wrote:
I have the need to create a non persistable child object in the
jdoPreStore of a parent object. I then perform some tests on the parent
to determine if the child object needs to be persisted or not. If I leave
the child non persistent it still writes to the database.
I was performing the follwoing piece of code
Class Parent {
// The relationship is a 0 to many
public Child createChild() {
Child child = .....//create non persistent object
child.setParent(this);
getChild().add(child);
It appears that if I remove the getChild().add(child). It does not
persist (as desired).
Is this correct behaviour?? I dont think that it should be, but if it is
then I have a further problem.
If that child object inherits from another object and you remove the
getChild().add(child) kodo outputs an invalid object to the database. It
doesnt insert a row to the child table. But it inserts a row to the
childs inherited object table. This is now an invalid object and will
fail upon loading.
Any help on this would be appreciated.
Thanks
Luke.
Steve Kim
[email protected]
SolarMetric Inc.
http://www.solarmetric.com -
Collection of non-persistent objects
Greetings
Is it possible to persist a Collection of non-persistent objects through the
kodo externalization feature? The non-persistent objects themselves are
externalizable, but I don't know how I would go about persisting a
Collection of them.
..droo.If you store them in some sort of externalized form in a single column it is
easy - just use externalization framework to ext and de-ext them to anf from
string. Couple of caveats you need to be aware of If your collection objects
are mutable:
1. You need to durty your collection field so it get prsisted on commit
2. on rollback Kodo will restore you collection content but not collection
member content. If they are mutable you will have to make their class
persistent with mapping "none" so they participate in transaction
"Drew Lethbridge" <[email protected]> wrote in message
news:BD0B44BF.544%[email protected]..
Greetings
Is it possible to persist a Collection of non-persistent objects throughthe
kodo externalization feature? The non-persistent objects themselves are
externalizable, but I don't know how I would go about persisting a
Collection of them.
.droo.
Maybe you are looking for
-
How many computers can you install adobe creative cloud on?
I purchased the Student discounted Creative Cloud and have downloaded it on a desktop at work and a workmates laptop. Can it be downloaded a third time onto my personal laptop?
-
How do I put my songs from iPod on my comp??
I restarted my whole entire comp today, so all my files were erased. But all my music was saved onto my iPod, and I would like to put all 744 songs on iTunes. How do I go about doing this???? I thought I had this earlier, but I'm totally confused now
-
SharePoint - Changed SQL Server but DPM still References Old One
Hello I have changed my SQL Server for SharePoint 2010 from Server1 to Server2. Everything is working OK. So I need to re-setup DPM as it is referencing the old instance. I have uninstalled the protection agent for SharePoint on my Web Front End. I h
-
Print Carbon Copy (CC) in smart-forms
Hi experts, My requirement is print Copy of form (duplicate Copy) in different Footer how to do it ?? Thanks in advanced. abhilash
-
How do I set an image to inline instead of floating in Pages?
In the old pages there was a button in the inspector that said floating or inline. I can't find it in version 5.5... How do I switch to inline? Can it be the default setting?