Entity manager with permanent buffering

EE application with JPA as a persistence layer. CMT Transactions.
I want that enitityManager will permanent buffer some long list of objects in the memory. All db writes will be done but instead of db read, the entityManager will read the objects right from the memory (by id). Every committed db transaction should also update the object on the list.
So if
entityManager.persist(anObject)
entityManager.commit();
then entityManager should put anObject to that list keeped in the memory.
I was thinking about DAO class with static lists with objects, which would layer JPA.
- (+) this would keep common list of object which would be accessible for various beans the sime time,
- (-) have no idea how to grab in that DAO class, that the transaction was committed with success and that the object on the list should be updated.
- (-) problems in the future for distributed persistence layer.
Anybody know if this is doable and won't break some jee spec?
Maybe something like that exists already?
Edited by: jpf on Apr 25, 2008 4:01 AM

EE application with JPA as a persistence layer. CMT Transactions.
I want that enitityManager will permanent buffer some long list of objects in the memory. All db writes will be done but instead of db read, the entityManager will read the objects right from the memory (by id). Every committed db transaction should also update the object on the list.
So if
entityManager.persist(anObject)
entityManager.commit();
then entityManager should put anObject to that list keeped in the memory.
I was thinking about DAO class with static lists with objects, which would layer JPA.
- (+) this would keep common list of object which would be accessible for various beans the sime time,
- (-) have no idea how to grab in that DAO class, that the transaction was committed with success and that the object on the list should be updated.
- (-) problems in the future for distributed persistence layer.
Anybody know if this is doable and won't break some jee spec?
Maybe something like that exists already?
Edited by: jpf on Apr 25, 2008 4:01 AM

Similar Messages

  • Database Entity Manager Concept

    Hello Forte-Users,
    currently I work with the Concept of the White-Paper:
    Forte Database Integration Patterns
    Forte Consulting
    May 1996
    to integrate Database-Access into my Warehouse-Application.
    Because the hole Application is delivered step by step and we are new
    in using Forte, I use for the first step only the patterns described for
    the DBEntityMgr to get a "feeling".
    The problem is, that if I use the DBEntityMgr-Concept and have many
    BaseClasses to access I have a lot of interface-calls like
    GetCustomer,GetProducts,etc..
    The Database Session Router will also not solve this "problem" in future,
    because the
    ApplicationEntityMgr has than the same problem.
    Question: Know anyone a way, based on the upon described facilities to use
    this strategy with a solution to make more "EntityMgrSO's" to get a smaller
    DBEntityMgr-Interface?
    The Database Session Router is planed for using when the Application should
    be used from more Users and when running the SO's on a WorkGroup-Server.
    Question: Know anyone a way there to split the ApplicationEntityMgr?
    Every reply is welcome.
    Thanks forward to all
    Joseph Mirwald
    Bachmeier & Sporrer
    GERMANY
    EMAIL: [email protected]
    Don't worry, which bug you wanna have today?

    ...snip
    >> The bad part is that now, the "client" of the entity manager
    must know
    >> which entity manger to call for any particular set of
    data. This negates
    >> a significant part of the advantage of using the single
    interface into the
    >> persistence layer.
    snip ...
    [KUBASADA Manjunatha] We can avoid this problem by having the
    EntityMgrSO method determine which entity manager to use. The client can
    pass a parameter indicating which object to get. The client call would
    look like,
    myobject = EntityMgrSO.GetEntity(myobjectindicator);
    OR
    EnitytMgrSO.GetEntity(output myobj : object);
    In the second case, the GetEntity method uses the run time type
    of myobj to determine which entity manager to call. In both cases the
    EntityMgrSO returns an object of type Object; the client would have to
    cast it to the appropriate type.
    Don, are there any downsides to this approach ?
    Manjunatha Kubasada
    Complete Business Solutions Inc.
    email : [email protected]
    Ph : (248) 488-2088 X 3480
    -----Original Message-----
    From: Don Nelson [SMTP:[email protected]]
    Sent: Saturday, November 29, 1997 4:05 PM
    To: Joseph Mirwald
    Cc: forte-users
    Subject: Re: Database Entity Manager Concept
    Joeseph,
    The concept of the entity manager having less interfaces is both good
    and
    bad. The good part is mostly related to development - splitting up
    the
    calls to the various SQL managers among several entity managers allows
    more
    flexibility in terms of which classes have to be checked out of the
    repository to add to or update the interfaces.
    >> The bad part is that now, the "client" of the entity manager
    must know
    >> which entity manger to call for any particular set of
    data. This negates
    >> a significant part of the advantage of using the single
    interface into the
    >> persistence layer.
    I've used both strategies in the past, and I tend to stay with one
    entity
    manager with a large number of interfaces. It moves the
    responsibility of
    knowing where to get the data from the client to the service, where it
    usually belongs. The only real time penalty is when you compile the
    partition - there will be more to compile. But since they are just
    interafaces, it shouldn't be that big of a deal.
    Don
    At 10:49 AM 11/28/97 -0500, Joseph Mirwald wrote:
    Hello Forte-Users,
    currently I work with the Concept of the White-Paper:
    Forte Database Integration Patterns
    Forte Consulting
    May 1996
    to integrate Database-Access into my Warehouse-Application.
    Because the hole Application is delivered step by step and we are new
    in using Forte, I use for the first step only the patterns describedfor
    the DBEntityMgr to get a "feeling".
    The problem is, that if I use the DBEntityMgr-Concept and have many
    BaseClasses to access I have a lot of interface-calls like
    GetCustomer,GetProducts,etc..
    The Database Session Router will also not solve this "problem" infuture,
    because the
    ApplicationEntityMgr has than the same problem.
    Question: Know anyone a way, based on the upon described facilitiesto use
    this strategy with a solution to make more "EntityMgrSO's" to get asmaller
    DBEntityMgr-Interface?
    The Database Session Router is planed for using when the Applicationshould
    be used from more Users and when running the SO's on aWorkGroup-Server.
    Question: Know anyone a way there to split the ApplicationEntityMgr?
    Every reply is welcome.
    Thanks forward to all
    Joseph Mirwald
    Bachmeier & Sporrer
    GERMANY
    EMAIL: [email protected]
    Don't worry, which bug you wanna have today?
    ============================================
    Don Nelson
    Regional Consulting Manager - Rocky Mountain Region
    Forte Software, Inc.
    Denver, CO
    Corporate voice mail: 510-986-3810
    aka: [email protected]
    ============================================
    "The good thing about drawing a tiger is that it automatically makes
    your
    picture fine art." - Hobbes

  • Problem with non-container managed entity manager

    i am working on a project, in which i am using entity beans.i use netbeans, glassfish as application server and toplink as persistence provider .
    i created a java class that handles all the operations with the entitys, which means i using non-container managed entity manager.
    in the constructor
    try{
                EntityManagerFactory emf = Persistence.createEntityManagerFactory("voidPU");
                entityManager = emf.createEntityManager();
            catch(Exception ex){
                throw new EJBException(ex.getMessage());
            }then i call a function in this class from a servlet
    the code of the function
    List users = null;
            try {
                ProgLanguages progLanguage = entityManager.find(ProgLanguages.class, languageId);
                users = (List) progLanguage.getUserIdCollection();
            catch(IllegalStateException illegalStateException){
                throw new EJBException(illegalStateException.getMessage());
            catch(IllegalArgumentException illegalArgumentException) {
                throw new EJBException(illegalArgumentException.getMessage());
            }i got an IllegalArgumentException saying Unknown entity bean class: class vanguard.server.entity.ProgLanguages, please verify that this class has been marked with the @Entity annotation
    what confuses me is that sometimes it works and most of the time it does not work, have i made anything wrong?, or there is a problem with any of the tools netbeans, glassfish, or toplink?

    Is it always the same entity that is reported as 'unknown' ? You mention that it works sometimes but is it the same deployment and the same code that works? The first thing I would verify is that the ear is being created as expected by netbeans. Check the persistence.xml file and verify that all of the classes are listed that will be used as entities.
    --Gordon                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Is it possible to map the cmp fields of the entity bean with out dictionary

    Dear sirs,
    I have created the EJB project module and WEB Module. Now i have to map the CMP fields of the entity bean to the underlying table. Is it possible to map the cmp fields of the entity bean with out java dictionary? If yes how can we do that.
    I have got some error while mapping an EJB's CMP fields to the table through dictionary. I was actually intended to map 79 fields but it gives an error that more than 64 fields are not allowed while building the dictionary.
    1. Can you tell me what could be the possible reason?
    2. Is it possible to map the cmp fields of the entity bean with out java dictionary? If yes how can we do that.
    Kindly helo me,
    Sudheesh K S

    Hi,
    Sudheesh please check up if the below link helps,there are other ways of writing the persistent.xml for container managed entity bean.
    http://help.sap.com/saphelp_nw04s/helpdata/en/9b/f695f0c84acf46a4e0b31f69d8a9b7/frameset.htm, probably in the studio you cannot browse through tables not in  the java dictionary,but manually editing it may still solve the problem.
    Also here is another link that specifies the databases supported by J2EE Engine.
    http://help.sap.com/saphelp_nw04s/helpdata/en/66/a5283eeb47b40be10000000a114084/frameset.htm
    The below link shows how to specify the database vendor and datasource
    http://help.sap.com/saphelp_nw04s/helpdata/en/e1/67fc3ee241ba28e10000000a114084/frameset.htm
    Hope you are able to solve the problem.
    Do let us know if you come up with the solution.
    Regards,
    Harish
    Message was edited by: HARISH SUBRAMANIAN

  • Entity bean with primary key generated by trigger

    Hi,
    We have a table(oracle) with one column as primary key,
    but the primary key is generated by trigger every time
    a new row is inserted into this table, inside the trigger,
    it uses oracle sequence to get the next val.
    If we want to use entity bean with it, what should we specify, it's not application-managed primay key, it's
    not auto-generated primary key either. How can we resolve
    it without change the database part.
    Any thought is appreciated.
    Thanks
    afang

    The code is already there with JDBC call inserting
    into the table, the inserting trigger then will generate
    sequence key and being inserted into primary key column.
    Now wondering if it's possible to change the code to use entity bean but without modifying the trigger (since it contains other business logics).

  • Entity manager Slow down

    Hey all Well I was just wonder if you guys could give me some insight? I am using the entity manager and It seems like I can do a transaction.. But as I keep doing the transaction to add elements.. It runs fine but then all of a sudden it just hangs? here my code? any insight would be greatly appreciated.. even if its just a theory
    selectedCustomer.getLevelIdSellCollection().add(item);               
    EntityTransaction tx = getEntityManager().getTransaction();
                    tx.begin();
                    getEntityManager().merge(Customer);
                    tx.commit();
                    getEntityManager().refresh(Customer);
                                   Message was edited by:
    jbayuga
    Message was edited by:
    jbayuga

    Welcome to the forum.
    If you have created either a Roll, or Crawl, with the Animation Preset, then you will want to increase the Duration of that Title, to slow it down. You can do this by click+dragging on the Tail of the Title.
    Or, you can create a static Title, then animate it by Keyframing the Fixed Effect>Motion>Position over time. That allows for much more control.
    Good luck,
    Hunt

  • Recommended way of getting entity manager from pojo class

    Hi,
    In our application we have the need or retrieving entity manager from 'pojo' classes.
    More specifically we have singleton classes which act as 'data' repositories and are accessed from both servlets and ejb.
    I'm aware that the repositories classes might be problematic, but in the current stage we can't perform significant change in application structure so I am looking for a 'fast' solution as possible.
    The best way will be to lookup entityt manager in JNDI, but as I undestand this feature is not avaialabe in weblogic.
    I understand that the preffered way for getting entity manager in such situation is by using @PersistenceUnit annotion on the calling location and lookup entityManager by that name in the pojo. This is however problematic for us since since we access the repositories from variouse locations (many different classes).
    Possible additional solutions we thought of:
    - creating an 'entity manager factory' locator ejb. This is an ejb with no transaction attribute, which has one method getEntityManagerFactory. It injects entityManagerFactory and returns it. This is the fastest soltion to implement. Is this a valid one?
    - using application managed entity manager in such situations. We have a problem doing so now because the creation seems to fail for variouse reasons.
    What is the recommended way?
    Thanks.

    To obtain an EntityManager instance, first must obtain an EntityManagerFactory instance by injecting it into the application component by means of the javax.persistence.PersistenceUnit annotation:
    @PersistenceUnit
    EntityManagerFactory emf;
    Then, obtain an EntityManager from the EntityManagerFactory instance:
    EntityManager em = emf.createEntityManager();
    http://download.oracle.com/javaee/5/tutorial/doc/bnbqw.html
    Edited by: dvohra16 on Apr 14, 2011 5:06 PM

  • JPA and Entity manager.

    Hi all,
    I have a "simple" question:
    Should I create a class to manage entity manager and entity manager factory on JPA2?
    Why do I ask that? Because I read on J2EE tutorial:
    With a container-managed entity manager, an EntityManager instance’s persistence context is automatically propagated by the container to all application components that use the EntityManager instance within a single Java Transaction Architecture (JTA) transaction.
    To obtain an EntityManager instance, inject the entity manager into the application component:
    @PersistenceContext
    EntityManager em;
    I'm using JSF2, JPA2, JTA and Glassfish3.1 on the NetBeans 7.0.1.
    The wizard that creates the JSF's pages from entity class does a good work but I have some problem in the other classes.
    When I call EntityManager it returns null!
    The strange thing is that it works properly the first time, when I recall the EntityManager from another xhtml page and from another class the entity manager returns NULL!
    So I would understand if the creation of a class for manage the EntityManagerFactory and EntityManager could help me.
    Thank you for your future help!

    Filippo Tenaglia wrote:
    Hi all,
    I have a "simple" question:
    Should I create a class to manage entity manager and entity manager factory on JPA2?That question is far from complete, as the answer to this one is "depends on what you want to do!"
    Why do I ask that? Because I read on J2EE tutorial:
    With a container-managed entity manager, an EntityManager instance’s persistence context is automatically propagated by the container to all application components that use the EntityManager instance within a single Java Transaction Architecture (JTA) transaction.
    To obtain an EntityManager instance, inject the entity manager into the application component:
    @PersistenceContext
    EntityManager em;
    Given this information...
    I'm using JSF2, JPA2, JTA and Glassfish3.1 on the NetBeans 7.0.1.That answer to your question is "NO", because you have a container available to you that can do the work (Glassfish). It makes no sense using Glassfish and then purposely ignoring the features it has to offer.
    Lets get back to basics: you are doing something wrong here. You have to figure out what, you can only do that if you keep studying and getting a more complete understanding. If you are having trouble realizing that, perhaps you should start over without the help of any wizard at all; wizards are only useful when you are already experienced, right now the fact that code is generated is hindering you a lot because you will have a strong impulse to believe there can be no mistake; unfortunately there is no such safety net. The fact that you used the word "weird" is enough proof of this by the way. There is nothing weird here, just a mistake being made that has to be corrected.
    And for the future: what IDE (Netbeans in your case) you use to develop really makes absolutely no difference at all. What is more interesting is which version of Java your are using, which can likely be Java 6 or Java 7 nowadays.

  • Error While Deploying A CMP Entity Bean With A Composite Primary Key

    Hello all,
    I have a problem deploying CMP Entity beans with composite primary keys. I have a CMP Entity Bean, which contains a composite primary key composed of two local stubs. If you know more about this please respond to my post on the EJB forum (subject: CMP Bean Local Stub as a Field of a Primary Key Class).
    In the mean time, can you please tell me what following error message means and how to resolve it? From what I understand it might be a problem with Sun ONE AS 7, but I would like to make sure it's not me doing something wrong.
    [05/Jan/2005:12:49:03] WARNING ( 1896):      Validation error in bean CustomerSubscription: The type of non-static field customer of the key class
    test.subscription.CustomerSubscriptionCMP_1530383317_JDOState$Oid must be primitive or must implement java.io.Serializable.
         Update the type of the key class field.
         Warning: All primary key columns in primary table CustomerSubscription of the bean corresponding to the generated class test.subscription.CustomerSubscriptionCMP_1530383317_JDOState must be mapped to key fields.
         Map the following primary key columns to key fields: CustomerSubscription.CustomerEmail,CustomerSubscription.SubscriptionType. If you already have fields mapped to these columns, verify that they are key fields.Is it enough that a primary key class be serializable or all fields have to implement Serializable or be a primitive?
    Please let me know if you need more information to answer my question.
    Thanks.
    Nikola

    Hi Nikola,
    There are several problems with your CMP bean.
    1. Fields of a Primary Key Class must be a subset of CMP fields, so yes, they must be either a primitive or a Serializable type.
    2. Sun Application Server does not support Primary Key fields of an arbitrary Serializable type (i.e. those that will be stored
    as BLOB in the database), but only primitives, Java wrappers, String, and Date/Time types.
    Do you try to use stubs instead of relationships or for some other reason?
    If it's the former - look at the CMR fields.
    If it's the latter, I suggest to store these fields as regular CMP fields and use some other value as the PK. If you prefer that
    the CMP container generates the PK values, use the Unknown
    PrimaryKey feature.
    Regards,
    -marina

  • My drive recently had to be replaced with a new one installed by Apple they reinstalled all my stuff from my time machine. Most my programs had to be updated which I managed with a little help from my friends, but the last one that I can't solve is

    My IMAC OSX 10.6.8   2.8 GHz intelcore  2Duo 4GB 800 Mhz DDR2 SDRam recently had to have its hard drive replaced by apple thy actually had to give me a larger one because mine was no longer available,They also reinstalled all my programs and data from my 2 terrabite time machine back up. I got my system home and found that I had to upgrade most of my programs which I managed with a little help from my friends, but I still have one problem that I can't solve I have a Nikon Coolpix S6 that I have Been Syncing with my Iphoto since I've got it 3 years ago and now when I place it in the cradle the program reconizes it and says that it is going to start to import the new photos the little white wheel in the center of the screen starts spinning but nothing else happens. I checked all my connections and they are goog plus I even downloaded a nikon progam just to double check the camera & cradle and it works there but it wont pair off with my IPhoto.

    First go to iPhoto Preferences, look in both General and Advanced tabs to make sure that things are set to import from camera into iPhoto.
    Then if that doesn't help, connect the camera and open Image Capture in your Applications > Utilities folder and see if you can use Image Capture to reset the import path from the camera to iPhoto.
    Image Capture: Free import tool on Mac OS X - Macgasm
    Message was edited by: den.thed
    Sorry John, I didn't see your post when I clicked the reply button. Dennis

  • Multiple users accessing entity bean with same PK

    Hi,
    Some body please clarify the below issue.
    (EJB 1.1, WAS3.5)
    I have two app servers and two clones each clone is running in each app server.
    Stateful session bean access Entity beans to update/read record in the database.
    According to my requirement multiple users can access the same entity data (same primary key). Suppose user A created a Stateful session bean SB1 and the SB1 created Entity1 with PK1, this is happening at clone1.
    User B accessed the site and the request went to Clone2 and a new SB2 created, but the SB2 need to access the database with Same PK1.
    For the above situation, I guess container can not create a new Entity bean with PK1 because EB with PK1 is already there and it tries to allocate same EB1 with SB2, so if two requests are concurrent do the SB2 wait to get the handle of the EB1?
    Is there any way to create two Entity beans with same Primary Key at the same time but in different clone?
    Thanks,
    Sagar

    Hi,
    The concurrency level has to be set at the level of database and the database will take care of consistency & integrity of the data. So specity the concurrency level on the database connection in each appserver.

  • How to use application managed entity manager in EJB?

    I finish reading The EntityManager Interface in JEE tutorial.
    I know I can use container manager entity manager in EJB, but I want to explore how to use application managed entity manager in EJB.
    Can I use application managed entity manager in EJB (container management JTA transaction is used)? Where do I should close entity manager if can?
    The following is an example from JEE tutorial, but didn't find where to calose entity manager. and can I create mutiple EntityManagerFactory objects and Entity Manager objects to use them in a JTA transaction?
    @PersistenceUnit
    EntityManagerFactory emf;
    EntityManager em;
    @Resource
    UserTransaction utx;
    em = emf.createEntityManager();
    try {
      utx.begin();
      em.persist(SomeEntity);
      em.merge(AnotherEntity);
      em.remove(ThirdEntity);
      utx.commit();
    } catch (Exception e) {
      utx.rollback();

    Seems like a very poor example, the whole power of EJBs is to use Container Managed Transactions so you don't NEED to manage the transaction and the entity manager yourself. What you posted is code I would expect in a non-JEE application, or in a piece of code which requires fine-tuned transaction boundaries such as batched data importing logic.
    If I were you I'd research JPA in steps.
    a) learn about JPA as an API outside of the scope of EJBs (recommended reading: the book 'Pro JPA 2')
    b) learn about Container Managed Transactions in EJBs
    c) learn about Bean Managed Transactions in EJBs
    Right now you're rushing into c). I can understand that it raises many question marks at this point.

  • How many domains can Prime Collaboration Advanced manage with the BE6000?

    The BE6000 Administration guide states that "Most BE6K deployments have a single domain as part of a Standard Prime installation. Multiple domains are available with Prime Collaboration Advanced (available for purchase) that can be used for complex Business Edition 6000 deployments."
    How many domains can Prime Collaboration Advanced manage with the BE6000 solution? How do we order and deploy Prime Collaboration Advanced with the BE6000 solution?

    http://docwiki.cisco.com/wiki/System_Capacity_for_Cisco_Prime_Collaboration_10.0

  • How do I disable Firefox's Download functionality, I would like to use another download manager with Firefox...many thanks Bruce

    Hi I am using version 3.6.15 with Windows 7, I would like to use another download program in place of Firefox's default option, how can I disable this in Firefox
    Many thanks
    Bruce Baxter

    Use this extension to integrate an external download manager with Firefox. <br />
    https://addons.mozilla.org/firefox/220/<br />
    http://www.flashgot.net/whats

  • Problem of creating workbook with permanent template?

    Hi all,
    Iam facing some problem while creating the workbook with permanent template.Let me expalin in detail.
    I have created 3 queries (ex:Stock) and i have to insert these in one workbook with permanent template.I  had selected the the permanent template option in settings also.iam able to insert the 3 queris and iam not getting the permanent tempalate.which is mandatory.
    I tried saving the existing workbook with same tempalate and removed the query and tried to insert the queries but iam getting <b>abbort system error in program</b>
    Pls help me out of this issue.
    Thanks and regards,
    Rajeev

    Hi Joe,
    We've seen this error when using express VI's inside of template VI's which are loaded using VI server. Are you doing that? If yes, then take all the express VIs that are inside the template VI and turn them into static subVIs.
    I don't know if it will help in your case, but let's try it.
    Regards,
    Luca
    Regards,
    Luca

Maybe you are looking for

  • How to stop workitem complete or how to keep work item in inbox based on conditions even if it completed

    Hi, my requirement is to call webdyn pro screen from workflow.. i am calling webdynpro screen by using FM :CALL_BROWSER from workflow. when webdyn pro screen is called user will enter some values . if user closed webdyn pro screen with out entering a

  • Generating a list of dates between 2 dates

    hi all, I have a table which looks something like this. Table_A (emp_id number, str_dt date, end_dt) Lets suppose the data is as below. emp_id str_dt end_dt 1 01-may-2006 03-may-2006 2 05-may-2006 12-may-2006 3 06-jun-2006 08-jun-2006 Now i need a qu

  • Vendor Master Record - Extracting Data?

    Is there some way to extract all data from the Vendor Master Records in a cleansing client, so that it can then be loaded to the production client?

  • Websafe fonts changing in design view, but not in browsers

    ive currently got a website with font thats extremely hard to read for my real estate company.  I can change it in dreamweaver just fine and it shows in design view, but upon previewing in a browser it does not work, just reverts back to the old horr

  • New service 30 day policy question

    Long story short, i was told by a verizon rep over the phone before i even became a customer, if i order a droid2, can i swap it for the droid x within my 30 days.  Due to at the time the droidx wasnt and still isnt available, and it has yet to be in