Equality between primitive and persistent objects

Folks,
I have discovered by chance that the KODO Query implementation allows me
to test for equality between an Integer and a persistent object. This is
actually phenomenally useful because it allows me to easily work around
some really inefficient auto-generated SQL (see below).
I couldn't find anything about this feature in the JDO specs. Is it
accidental? Is it supported, or likely to disappear in future versions?
Dave Syer.
# 'bean' is an object already loaded from the persistence store
javax.jdo.JDOHelper.getObjectId(bean)Bean-101
# it has one mutable property, which is persistence capable
# and also a read-only property which is the database id
# (Integer) of the property:
javax.jdo.JDOHelper.getObjectId(bean.getProperty())Property-371
bean.getPropertyId()371
# get an extent for querying (pm is the PersistenceManager)
ex=pm.getExtent(Bean,0)# First do a query on property...
qu=pm.newQuery(ex);
qu.declareParameters("Property id1");
qu.setFilter("property == id1")# ...generates SQL with additional unnecessary(?) Cartesian join
# to PROPERTY table:
res=qu.execute(bean.getProperty())# resulting SQL:
# SELECT t0.PROPERTY_ID, t0.PROPERTY_ID FROM BEAN t0, PROPERTY t1
# WHERE (t0.PROPERTY_ID = 371 AND t0.PROPERTY_ID =
# t1.PROPERTY_ID)
# Now do a query on propertyId (Integer)...
qu=pm.newQuery(ex);
qu.declareParameters("java.lang.Integer id1");
qu.setFilter("propertyId == id1")# ...but parameter value is allowed to be a Property -- magically
# turned into an integer when the SQL is generated:
res=qu.execute(bean.getProperty())# resulting SQL:
# SELECT t0.PROPERTY_ID, t0.PROPERTY_ID FROM BEAN t0 WHERE
# t0.PROPERTY_ID = 371

It is accidental and unsupported.Is there any other way to get round the 'unnecessary join' issue that I
mentioned briefly in my original posting? In a real world example, I was
able to improve performance of a single query by a factor of 100 (and my
DB experts tell me there was no way to optimise indexes or anything at the
RDBMS level and achieve the same result).
DAve.

Similar Messages

  • 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,
    Mike

    Hi 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.

  • Difference Between Maps and Value Objects

    Hi Guys
    Can you please help me differentiate between HashMap and Value Object Design patterns. The trade offs of each and how to choose between the two patterns.

    It really depends upon what you really want to do:
    - If you want to transfer simple objects using their inherent structure, use your DomainObject itself or if you really need to, use a ValueObject
    - If you want to transfer a lot of similar or even different objects with unique keys, use some Map.
    Using a HashMap, you might need to consider:
    - The hashing can significantly increase your CPU load, if you are doing too much. For example you can define your hashValue() to return just the PrimaryKey, or it's hashValue() if it's an Object. And equals() needs only to compare the PrimaryKey as well. This semantic results in two objects being equal, if they have the same PrimaryKey. You may define an additional deepEquals() method, to see if an updated version contains changes to the stored version, if this is needed.
    - If you keep around references in a Map without clearing them, when you don't need them any more, the Map will increase in size. If you want to keep them, but only as memory alows, you might even consider using WeakReference<T>.
    Together with the rules provided by krunals, I hope this helped a bit...

  • Explicity mapping between ActionScript and Java objects for the BlazeDS Messaging Service

    The BlazeDS documentation shows how to explicitly map between ActionScript and Java objects. For example, this works fine for RPC services, e.g.
    import flash.utils.IExternalizable;
    import flash.utils.IDataInput;
    import flash.utils.IDataOutput;
    [Bindable]
    [RemoteClass(alias="javaclass.User")]
    public class User implements IExternalizable {
            public var id : String;
            public var secret : String;
            public function User() {
            public function readExternal(input : IDataInput) : void {
                    id = input.readObject() as String;
            public function writeExternal(output : IDataOutput) : void {
                    output.writeObject(id);
    and
    import java.io.Externalizable;
    import java.io.IOException;
    import java.io.ObjectInput;
    import java.io.ObjectOutput;
    import java.util.HashSet;
    import java.util.Iterator;
    import java.util.Set;
    public class User implements Externalizable {
        protected String id;
        protected String secret;
        public String getId() {
            return id;
        public void setId(String id) {
            this.id = id;
        public String getSecret() {
            return secret;
        public void setSecret(String secret) {
            this.secret = secret;
        public void readExternal(ObjectInput in) throws IOException,
                    ClassNotFoundException {
            id = (String) in.readObject();
        public void writeExternal(ObjectOutput out) throws IOException {
            out.writeObject(id);
    If I called an RPC service that returns a User, the secret is not sent over the wire.  Is it also possible to do this for the messaging service? That is, if I create a custom messaging adapter and use the function below, can I also prevent secret from being sent?
    MessageBroker messageBroker = MessageBroker.getMessageBroker(null);
    AsyncMessage message = new AsyncMessage();
    message.setDestination("MyMessagingService");
    message.setClientId(UUIDUtils.createUUID());
    message.setMessageId(UUIDUtils.createUUID());
    User user = new User();
    user.setId("id");
    user.setSecret("secret");
    message.setBody(user);
    messageBroker.routeMessageToService(message, null);

    Hi Martin. The way that AMF serialization/deserialization works for BlazeDS is the same regardless of which service is being used, so yes that code will work for messaging as well. On the server, the serialization/deserialization of messages happens at the endpoint. For an incoming message for example, the endpoint deserializes the message and then hands it off to the MessageBroker which decides which service/destination to deliver the message to.
    That was a good question. Thanks for asking it. Lots of people are used to doing custom serialization/deserialization with the RPC services (RemoteObject/RemotingService) but I'm not sure everyone realizes they can do this for messaging as well.
    -Alex

  • Difference between durablity and persistance

    hi,
    I am new to JMS and could anyone tell me what is the difference between durablity and persistance?
    As far as i understood, persistance is with respect to the JMS Provider. Say, for example when the JMSProviderServer crashes, and if the message is persistant(by setting as a parameter in setDeliveryMode() method), when the server starts up, the message will be reaching the intended Message Consumers.
    Durability is with respect to the Message Consumers. If the message consumers are subscribed as durable, then even if they are not active they will receive the message when they get connected to the Provider at a later time.
    Is my understanding right?
    If it is, i am getting one more doubt. What happens, if i set the message as nonpersistant type and publish to a topic and the durable subscriber is not active when the message is published? Will the durable subscriber be able to get the published message, when it becomes active again?
    thanks,
    desigan

    Your understanding is correct. Messages can be persistent. Subscribers can be durable.
    The specification is somewhat loose on non-persistent messages being sent to an inactive durable subscriber. First of all anything that is non-persistent is already a candidate for being dropped at anytime. Having said that, it is anti-social to drop messages, even for inactive durable subscribers.
    Mileage varies by vendor though. Check for yourself to be sure.

  • Reg Differrences between SynBo and Data Object

    Hi,
            I want to know the architectural diffrences between a SyncBo of MI 2.5 and Data Object of NWM 7.1.  As it is given in help.sap.com documentation I think A data object support multiple levels of parent- child hirearchy where as a SyncBo is limited to one level of Header and Items.Similarly do any other differences exist?
    2) In what way A data Object concept is better than that of a Synco.?
    3) For manipulating the data of a data Object on Front end, Can we Use the existing SmartSync API of MI 2.5, or a seperate API for client side is going to be released?
    Thanks in Advance,
    Rajesh

    Hello Rajesh,
    1. The differences are small. You pretty much highlighted the biggest one (multi child node). Other differences exist in the fact that a SyncBO is linked to a backend BAPI as the DO is not (you would usually create the DO with the fields you need and then have backend adapters to fill it). Lifecycle of the DO is also different. Even release, non destructive change can happen and old application as well as new application will work at the same time. I can list a couple more, but I think you get that a SyncBO is different than a DO (even if in our development we still get mix both wording:))
    2. Yes DO is a better concept than SyncBO.
    3. There are 3 ways of accessing API on the client side. The first is the old SmartSync API which is only used in backward compatibility application (MAM for example). It should not be used for new development, but only to leverage existing one. After that you have two new frameworks for laptop and for PDA that you can find in NWDS 7.1. They reviewed the naming so I am not sure of the current ones, but I think it is something like Mobile Application for Handheld and Mobile Application for Laptop. Those two new framework uses WebDynPro flavored UI and provide access to the sync/data layer.
    Thank you,
    Julien.

  • Relation between Roles and Course/Object ID

    hi
    Please tell me the HR-infotype having roles/position/job in relation with Course/object Id.
    HRP1000 have only courses .
    or please tell me how to make relation between two i.e. roles and course/object id
    S@chin

    all these
    Characterstic will available in differnt Infotypes   Check the tcode PP01
    and check with the help of the Objects
    for Course ID

  • Use of Ref and Persistent Objects

    Hi,
    I am using OTT and I have created a sub class for the OTT generated class
    i.e.,
    class A:public PObject//OTT generated
    class B:public A//created by me
    for Class B I need to write a static function queryKey() which will return a pointer to persistent object of class B,
    i.e.,
    B* B::queryKey(Number c,Number d);
    I have implemented it something like this...
    B* B::queryKey(      OCCI_STD_NAMESPACE::string c,
                        oracle::occi::Number d,
                        oracle::occi::Number e)
         Statement *stmt=NULL;
         ResultSet *rset=NULL;
         CCPDKey *handle=0;
         try
              string query="SELECT REF(a) FROM ";
              query=query+tableName+ (" a WHERE C=:1 AND D=:2 AND E=:3 ");
              stmt=conn-&gt;createStatement(query);
              stmt-&gt;setString(1,c);
              stmt-&gt;setNumber(2,d);
              stmt-&gt;setNumber(3,e);
              rset=stmt-&gt;executeQuery();
              if(rset-&gt;next())
                   Ref &lt; B &gt; r1(rset-&gt;getRef(1));
                   handle=r1.ptr();
         catch(...)
              stmt-&gt;closeResultSet (rset);
         conn-&gt;terminateStatement (stmt);
              throw;
         stmt-&gt;closeResultSet (rset);
    conn-&gt;terminateStatement (stmt);
         return handle;
    Is this the correct way of doing it,
    Will the persistent object pointed by handle get destroyed as the scope of Ref i.e.,r1 ends..?
    If so, what is the correct way of doing it..?
    I need this method to return a B*.
    If the way I have used is correct,Do I need to delete the variable handle once I am done using it..?I saw in "Using OCCI: Best Practices" that the persistent object should not be deleted unless you are doing rollback.
    I am new to OCCI and i am confused
    Please help
    Ajey

    In the function B::queryKey(), the Ref<B> variable will go out of scope at the end of the if {} statement and the Ref will be unpinned. So, the "handle" object pointer variable will be pointing to an object that could be freed anytime by the garbage collector.
    Can you change your design to return a Ref<B> from B::queryKey()? If you want to return the object pointer directly then you will have to manage pining/unpining of the object. With Refs, the pining/unpining is transparently managed by OCCI and with the "->" operator you can write code which is the same as with the object pointer.
    Thanks,
    Shankar

  • Difference between  BOL and Genil Objects

    Hi Team
    Am very  new to  CRM.So pls let me know the difference between the BOL and GENIL objects and their respective importance.
    Thanks

    Hi,
    The BOL and GenIL essentially refer to the layers that handles the user interface in SAP CRM.
    The GenIL (Generic Interaction Layer) consists of one implementation class that always derives from one of the two classes and implements a set of methods to provide the functionality. GenIL is like a bridge between the backend APIs and the UI i.e. for
    a given UI, it identifies which APIs need to be called and also re-formats data accordingly.
    The BOL (Business Object Layer) consists of upto 7 different kinds of objects that are defined in a model. At runtime, the BOL layer will hold data that is used on the UI. BOL provides a consistent way of modelling data so that data access is consistent and the UI can also be built faster.
    Regards,
    Shiromani

  • What is the difference between StringBuffer and StringBuilder objects

    hi ,
    Please tell me what is the difference between stringBuilder and stringBuffer classes ..why stringbuffer classes is used more with multiple threads but not stringBuilder which is faster than stringBuffer objects
    Thanks in advance

    Odd. You answer your own question by paraphrasing the first paragraph of
    StringBuilder's javadoc:
    This class provides an API compatible with StringBuffer, but with no guarantee
    of synchronization. This class is designed for use as a drop-in replacement for
    StringBuffer in places where the string buffer was being used by a single thread
    (as is generally the case). Where possible, it is recommended that this class
    be used in preference to StringBuffer as it will be faster under most
    implementations.
    Do you really have a question?

  • The deffrent between children and visibles objects

    hi
    i have problem here because iam confusing between these things , i know that visible property has to values true and false , and addchild is another thing because when you have two objects
    then you put object 2 in object1 and i it will have its own x,y postion depend on that object , and object 1 is child for the main stage , but here is the problem
    i.ve opened discuss before this
    http://forums.adobe.com/message/4615780#4615780
    and when i remove the child , its effect will be there ?? on the stage !! it is like hiding object
    ? so iam very confuse now , also if removechild doesn,t remove the object from existing then how can i remove it??
    thank you and i hope you guys get what imean in my question
    please check this link (my old discuss)
    http://forums.adobe.com/message/4615780#4615780
    thank you

    thx , i did all these steps but in the bat still exist
    look
    1- remove it from display list
    in the main class
    if (hero.hitTestObject(portal3)){
          var map4:BACKGROUND = new BACKGROUND
          if(bat1.stage){
         removeChild(bat1)
         bat1.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
    2-remove it from the display list, remove all listeners and object references and null the object.
    in the bat1 class
    private function onRemovedFromStage(event:Event):void
       removeEventListener(Event.ENTER_FRAME, onEnterFrame);
       removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
       removeEventListener(Event.REMOVED_FROM_STAGE, onRemovedFromStage);
       null;
       trace("bat removed");
    thank you

  • Generics, Primitives, and Lightweight Objects

    One of the planned features for JDK 1.5 is autoboxing of primitives. Basically, treat primitives like objects.
    My big question: Are the generics and primitives ideas being reconciled?
    Speaking of primitives, David Bacon created a Java dialect called Kava (see link below). Briefly, it's precisely what I want inJDK 1.5.
    "Kava: A Java dialect with a uniform object model for lightweight classes"
    David F. Bacon, IBM T. J. Watson Research Center
    http://aspen.ucs.indiana.edu/CandCPandE/jg2001/C559bacon/c559Bacon02Kava.pdf

    Speaking of primitives, David Bacon created a Java
    dialect called Kava (see link below). Briefly, it's
    precisely what I want inJDK 1.5.I think you will be disappointed --- I would be very surprised if anything so radical was considered.

  • [MRS] Conflict in Infotype 0001 between A and S object type

    Hi,
    We use SAP MRS on top of our HR box. (sorry, I am not a SAP MRS expert so bear with me please....)
    As we activated PA-PD integration, whenever a Work Center (otype A) is assigned to an employee (otype P), it updates the Infotype 0001 accordingly (PLANS and OTYPE field) while also inserting a new entry into T528B and T528T tables.
    This is consistent with what the RHINTE30 program does (look at the $plste [S] and Work Center [A]):
    But, the employee is also assigned to a position (otype S)! It makes much more sense to have Position filled in the Infotype 0001 rather than Work Center!!
    Thus, our first approach would be to deactivate PA-PD integration for Work Center (otype A) and only leave it active for Position (otype S).
    Thanks in advance for your help.
    Best regards,
    Guillaume

    Guillaume,
    Has your issue ever been solved?
    Kind regards,
    Lieselot

  • Infocubes and info objects

    Hi guys,
            i'm new to BI. can any one differentiate between Infocubes and info objects..
    please be a bit specific.....

    Hi,
    An InfoCube describes (from an analysis point of view) a self-contained dataset, for example, for a business-orientated area. You analyze this dataset in a BEx query.
    An InfoCube is a set of relational tables arranged according to the star schema: A large fact table in the middle surrounded by several dimension tables.
    Use
    InfoCubes are filled with data from one or more InfoSources or other InfoProviders. They are available as InfoProviders for analysis and reporting purposes.
    Structure
    The data is stored physically in an InfoCube. It consists of a number of InfoObjects that are filled with data from staging. It has the structure of a star schema.
    The real-time characteristic can be assigned to an InfoCube. Real-time InfoCubes are used differently to standard InfoCubes.
    ODS versus Info-cubes in a typical project scenario
    ODS
    why we use ods?
    why is psa  & ods nessasary
    InfoObject: Basic building block of BW.. ( Its like a field )
    Definition
    Business evaluation objects are known in BI as InfoObjects. They are divide into characteristics (for example, customers), key figures (for example, revenue), units (for example, currency, amount unit), time characteristics (for example, fiscal year) and technical characteristics (for example, request number).
    Use
    InfoObjects are the smallest units of BI. Using InfoObjects, information is mapped in a structured form. This is required for constructing InfoProviders.
    InfoObjects with attributes or texts can  themselves also be InfoProviders (if in a query).
    Regards,
    Ram.

  • ABAP and ABAP Objects

    Hi ,
    What is the exact difference between ABAP and ABAP Objects?

    Hi,
    Look at:
    <a href="/people/dirk.feeken/blog/2007/07/06/abap-trial-version-for-newbies-part-17--your-first-abap-object Trial Version for Newbies: Part 17 - Your first ABAP Object</a>
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/1591ec90-0201-0010-3ba8-cdcd500b17cf">ABAP Code Sample for Objects</a>
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/2503f09c-0801-0010-dc89-80bab376e4b8">Object Oriented ABAP - Local and Global classes</a>
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/b6cae890-0201-0010-ef8b-f970a9c41d47">ABAP Code Sample to Learn Basic Concept of Object-Oriented Programming</a>
    <a href="https://sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/uuid/37c5db90-0201-0010-3a9b-d0a5288f3c15">Eight Reasons Why Every ABAP Developer Should Give ABAP Objects a Second Look</a>
    <a href="https://sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/uuid/3e59b790-0201-0010-88aa-bc8a7f95f6fb">Why use ABAP Objects</a>
    <a href="https://media.sdn.sap.com/public/eclasses/teched04/ABAP151_files/Default.htm#nopreload=1">ABAP Objects for Java Developers</a>
    Regards.
    Marcelo Ramos

Maybe you are looking for