Design decision: where to put transaction?

Hello, Java expert and System Anlysis, Architect around the world, pls help me on this:
There are two type of EJB, namely Session EJB and Entity EJB. Both of them can be used to manipulate the data in database. So, for the transaction, such as withdraw money from a bank, Session EJB or Entity EJB is best used to implement that transaction?
Thanks.

Hello
It depends on where you want to control the work flow. If you are planning to use the session bean as a session facade, and process work flow by handling entity beans from with in its methods, you must handle transactions in the session beans.
So, you can call withDrawMoney(double amt) on the session bean from the client, the session bean will handle the transaction. You can even define the transaction demarcation at the method level.
As a rule, I would handle transaction in a session bean, if I am not handling business logic in the entity bean.
Hope this helps.
Shiva Kolli
Hello, Java expert and System Anlysis, Architect
around the world, pls help me on this:
There are two type of EJB, namely Session EJB and
Entity EJB. Both of them can be used to manipulate the
data in database. So, for the transaction, such as
withdraw money from a bank, Session EJB or Entity EJB
is best used to implement that transaction?
Thanks.

Similar Messages

  • Where to put Transactions?

    We are going to devleop a project, in J2ee, in that we are using DAO pattern,
    we are using session beans for EJB and DAO class for Data Access,
    So in that case where i have to implement Transactions, in session bean or
    in DAO , pls reply with an ideal exampl, it is important

    Since you are using beans it would be a good idea to delegate transaction handling to the EJB container.. There are other frameworks for data access like hybernate which takes care of transaction management. You can set the transaction level in the deployment descriptor.

  • Where to put EJB design patterns?

    Im considering where to put the EJB design pattern classes and files.
    i.e. Facade, Data Access Objects, Transfer Objects, Delegate...
    I was thinking since the EJB business logics and implementation should be hidden from the user, then it is more logical to place these classes at the webapp.war inside of the ejb.jar.
    What are your thoughts guys?

    Photoshop patterns and normally stored in sets the set files have an extension of .pat.  You may also add individual patterns using menu Edit>Define Pattern.  In some Photoshop Pattern dialog you will see a little gear icon to open a Fly-Out menu in that menu there is a entry for Photoshop Preset Manager.  The are also other ways to get into the Preset manager.   In the preset manager you can manage many types of presets. Using its pull-down menu select patterns.  You can Load an save patterns sets.  To save a set tou heed to hilifht the paterns yoy want to include in the set.  You can also delete and rename patterns.

  • JPA Arhitectural Design Decision

    Hi,
    I'm building a 1 tier web shop, using mostly Ajax, Servlets and JPA and I need your advice on a design decision.
    When a user demands to see the products belonging to a particular category of products, my DAO object returns to the servlet a java.util.List<Product>, where Product is a JPA entity. In the servlet class I "manually" create the Ajax XML response, the user gets to see the products, everything is nice and great.
    I am not happy with the fact that the list of products remains detached in the servlet class, sort of say, and when another user demands to see the same products another list gets greated. These are objects that have method scope, but still they are on the stack, right? For 100 users who want to see 100 products each, the no. of objects created could cause the application to have a slower reponse time.
    So my question is about the design of the application.
    I obtain the list of products in the servlet class and construct the XML response. Right before sending the response, should I pass the list of products back to the DAO, and ask the EntityManager to merge the products? Will this reduce the no. of objects my application creates? Shouldn't I do this because I'm merging entities that have not been changed and the merge operation is time consuming?
    Should I not pass back the products to the DAO and set each product in the list to reference null and call System.gc() ?
    Keeping in mind, that my main concern is application response time, not reduced development time, are there any other suggestions you can make?

    first of all, a merge is only used to synchronize a changed entity that is not managed by an entity manager with the database. Why did you even come to the conclusion that you might need this?
    No you don't nullify the entities in the list. You let the entire list go when you are done with it. Manually nullifying can hinder the garbage collector, just don't do it unless you have a very good reason for doing so.
    Your main problem seems to be that you don't like the fact that you are fetching 100 objects for both users, putting duplicate objects in memory on the server. Are you sure this is a problem? You shouldn't be thinking about optimizations while you are still developing you know. I would wait until you are done, then profile the application to see where bottlenecks are; if fetching those 100 products turns out to take a lot of system resources, THEN optimize it.
    You may want to look into caching. If for example under water you use Hibernate as the persistence provider, search for "hibernate cache" using google.

  • Where to put the commit in the FORALL BULK COLLECT LOOP

    Hi,
    Have the following LOOP code using FORALL and bulk collect, but didnt know where to put the
    'commit' :
    open f_viewed;
    LOOP
    fetch f_viewed bulk collect into f_viewed_rec LIMIT 2000;
    forall i in 1..f_viewed_rec.count
    insert into jwoodman.jw_job_history_112300
    values f_viewed_rec(i);
    --commit; [Can I put this 'commit' here? - Jenny]
    EXIT when f_viewed%NOTFOUND;
    END LOOP;
    commit;
    Thanks,
    - Jenny

    mc**** wrote:
    Bulk collect normally used with large data sets. If you have less dataset such as 1000-2000 records then you canot get such a performance improvent using bulk collect.(Please see oracle documents for this)
    When you update records Oracle acquire exclusive lock for that. So if you use commit inside the loop then it will process number of records defined by limit parameter at ones and then commit those changes.
    That will release all locks acquired by Oracle and also teh memory used to keep those uncommited transactions.
    If you use commit outside the loop,
    Just assume that you insert 100,000 records, all those records will store in oracle memory and it will affect all other users performance as well.
    Further more if you update 100,000 records then it will hold exclusive lock for all 100,000 records addtion to the usage of the oracle memory.
    I am using this for telco application which we process over 30 million complex records (one row has 234 columns).
    When we work with large data sets we do not depends with the oracle basic rollback function. because when you keep records without commit itb uses oracle memory and badly slowdown all other processes.Hi mc****,
    What a load of dangerous and inaccurate rubbish to be telling a new Oracle developer. Commit processing should be driven by the logical unit of a transaction. This should hold true whether that transaction involves a few rows or millions. If, and only if, the transaction is so large that it affects the size constraints of the database resources, in particular, rollback or redo space, then you can consider breaking that transaction up to smaller transactions.
    Why is frequent committing undesirable I hear you ask?
    First of all it is hugely wasteful of rollback or redo space. This is because while the database is capable of locking at a row level, redo is written at a block level, which means that if you update, delete or insert a million rows and commit after each individual statement, then that is a million blocks that need to go into redo. As many of these rows will be in the same block, if you instead do these as one transaction, then the same block in redo can be transacted upon, making the operation more efficient. True, locks will be held for longer, but if this is new data being done in batches then users will rarely be inconvenienced. If locking is a problem then I would suggest that you should be looking at how you are doing your processing.
    Secondly, committing brings into play one of the major serialization points in the database, log sync. When a transaction is committed, the log buffer needs to be written to disc. This occurs serially for multiple commits. Each commit has to wait until the commit before has completed. This becomes even more of a bottleneck if you are using Data Guard in SYNC mode, as the commit cycle does not complete until the remote log is notified as written.
    This then brings us two rules of thumb that will always lead a developer in the right direction.
    1. Commit as infrequently as possible, usually at the logical unit of a transaction
    2. When building transactions, first of all seek to do it using straight SQL (CTAS, insert select, update where etc). If this can't be easily achieved, then use PL/SQL bulk operations.
    Regards
    Andre

  • JUnit, where to put my unit test

    Hi all,
    I have a question regarding unit test.
    I am working on a project which has multiple packages. I need to unit test every package using JUnit. One question I have is where to put my unit test. The options are:
    1. Write unit test as a separate package. This makes the code clear but only the public functions get tested or I have to make all functions public.
    2. Write unit test in the same package of the code to be tested. This makes writing test easier but putting test and code together makes the structure dirty.
    Please let me know your opinion and tell me how do you normally do this?
    Many thanks,
    Regards,
    Kevin

    It sounds like you're probably a beginner, so this might be overkill, but here goes anyway: You might want to investigate Maven, which defines a standard directory structure that includes a test tree separate from the production tree, but yet still in the same overall folder. The beauty of this design is that you can keep both production & test code together in source control, IDE projects, etc. but they don't interfere with each other.
    Even if you don't use Maven now, you might want to consider using their standard directory structure, as it is has stood the test of time, & would facilitate using Maven if you ever decide to in the future.

  • COPA vs. BCS design decisions (ex. profitability by customer in BCS)

    We are trying to meet a business goal of identifying gross profit by customer.
    We realize "customer" as a field in BCS is problematic, so we are thinking of only storing certain customers in BCS with a catch-all "Others" customer - with the goal of keeping the BCS data volume reasonable.
    Consider the scenario: US company sells material X qty 1 to Spain company for 100 with cost of 30 (therefore profit of 70)
    Spain sells same material X qty 1 to third-party customer for 120.
    Spain from a local perspective profits 20, however the group from an overall perspective profits 90 ( the US revenues of 100 eliminate against the Spain COGS of 100 so you are left with revenue of 120, COGS 30, profit 90 - from the group perspective ).
    We want to know how to see, on a customer level, the 90 profit from these transactions. 
    We do not believe COPA can do this, can this may be accomplished in BCS? 
    If you do a "one-sided" elimination (elimination driven by the revenue side only) of the intercompany revenue the system would not be able to reference customer on the elimination. We are wondering if this scenario of analyzing overall profit by customer can be accomplished by BCS functionality and are particularly interested in knowing what functionality you used to accomplish this requirement and in what sequence within the BCS close (BCS monitor).
    Thank you in advance for any input you may have.
    Also we are interested in any opinions/comments anyone may have about design decisions regarding BCS vs. COPA in BW.  BCS business content identifies a sample design for a BCS data model including item, company, movement type, trading partner, functional area, etc.  COPA (as configured in R3/ECC and extracted to BW) commonly features analysis by customer, material, etc.  Considering BCS features elimination functionality, what design concerns have people faced with respect to fields that they include in both reporting systems?  Obviously a prominent concern is sizing of the systems, but what common characteristics has anyone decided to feature in both systems? What considerations drove the decisions as to what common characteristics to feature in both BCS and COPA?

    Hi John,
    Reg, your last question - might be useful info in here, if you have not seen it yet:
    Re: Reports using COPA cube, BCS Cube

  • Architecture question...where to put the code

    Newbie here, so please be gentle and explicit (no detail is
    too much to give or insulting to me).
    I'm hoping one of you architecture/design gurus can help me
    with this. I am trying to use good principals of design and not
    have code scattered all over the place and also use OO as much as
    possible. Therefore I would appreciate very much some advice on
    best practices/good design for the following situation.
    On my main timeline I have a frame where I instantiate all my
    objects. These objects refer to movieClips and textFields etc. that
    are on a content frame on that timeline. I have all the
    instantiation code in a function called initialize() which I call
    from the content frame. All this works just fine. One of the
    objects on the content frame is a movieClip which I allow the user
    to go forward and backward in using some navigation controls.
    Again, the object that manages all that is instantiated on the main
    timeline in the initialize() function and works fine too. So here's
    my question. I would like to add some interactive objects on some
    of the frames of the movieClip I allow the user to navigate forward
    and backward in (lets call it NavClip) . For example on frame 1 I
    might have a button, on frame 2 and 3 nothing, on frame 4 maybe a
    clip I allow the user to drag around etc. So I thought I would add
    a layer to NavClip where I will have key frames and put the various
    interactive assets on the appropriate key frames. So now I don't
    know where to put the code that instantiates these objects (i.e.
    the objects that know how to deal with the events and such for each
    of these interactive assets). I tried putting the code on my main
    timeline, but realized that I can't address the interactive assets
    until the NavClip is on the frame that holds the particular asset.
    I'm trying not to sprinkle code all over the place, so what do I
    do? I thought I might be able to address the assets by just
    providing a name for the asset and not a reference to the asset
    itself, and then address the asset that way (i.e.
    NavClip["interactive_mc"] instead of NavClip.interactive_mc), but
    then I thought that's not good since I think there is no type
    checking when you use the NavClip["interactive_mc"] form.
    I hope I'm not being too dim a bulb on this and have missed
    something really obvious. Thanks in advance to anyone who can help
    me use a best practice.

    1. First of all, the code should be:
    var myDraggable:Draggable=new Draggable(myClip_mc);
    myDraggable.initDrag();
    Where initDrag() is defined in the Draggable class. When you
    start coding functions on the timeline... that's asking for
    problems.
    >>Do I wind up with another object each time this
    function is called
    Well, no, but. That would totally depend on the code in the
    (Draggable) class. Let's say you would have a private static var
    counter (private static, so a class property instead of an instance
    property) and you would increment that counter using a
    setInterval(). The second time you enter the frame and create a new
    Draggable object... the counter starts at the last value of the
    'old' object. So, you don't get another object with your function
    literal but you still end up with a faulty program. And the same
    goes for listener objects that are not removed, tweens that are
    running and so on.
    The destroy() method in a custom class (=object, I can't
    stress that enough...) needs to do the cleanup, removing anything
    you don't need anymore.
    2. if myDraggable != undefined
    You shouldn't be using that, period. If you don't need the
    asset anymore, delete it using the destroy() method. Again, if you
    want to make sure only one instance of a custom object is alive,
    use the Singleton design pattern. To elaborate on inheritance:
    define the Draggable class (class Draggable extends MovieClip) and
    connect it to the myClip_mc using the linkage identifier in the
    library). In the Draggable class you can define a function unOnLoad
    (an event fired when myClip_mc is removed using
    myClip_mc.removeMovieClip()...) and do the cleanup there.
    3. A destroy() method performs a cleanup of any assets we
    don't need anymore to make sure we don't end up with all kinds of
    stuff hanging around in the memory. When you extend the MovieClip
    Class you can (additionally) use the onUnLoad event. And with the
    code you posted, no it wouldn't delete the myClip_mc unless you
    program it to do so.

  • HELP !!!!!! Design decision...!!!!!

    Hello,
    I am in a dilemma of making a design decision . We are developing a business tier component. This is going to talk to webservices on the backend. Right now it is going to integrate with 2 different backend systems through web services. In future it might support more of such backend systems.
    And there are clients (web app, xml app) who interface with the component.
    Most of the data elements passed over to backend systems is similar for both the systems, but some are different.
    Now is it a good design to make 2 different client interfaces for 2 backend systems ? so that ,clients upfront decide which interface to use. This is more cleaner and easier implementation.
    Or is it good to have a generic interface, and component then figures out which data to use and to which backend system to talk to.
    Please help,
    Thanks

    There are several patterns that could apply, but the most widly used is probably the MVC (Model View Controller) pattern.
    With the pattern the View layer is the front end (in your case this would be the web app / xml app).
    The Controller would be your middle tier, this layer is responsible for relaying requests of the View layer to the Model layer.
    The Model layer would be your backend webservices.
    As said, the controler is responsible for relaying the requests from the view layer to the correct webservice. This means you need to have some way to know how to do this. You can employ several methods to do this.
    You could have different methods for the different webservices, this is the most straight forward way.
    Or you could look at the provided parameters and decide where you need to go based on that. This is slightly more difficult, but when you have two or more webservices that do almost the same thing, this might be the better way to go.
    If you really wanted to make things fancy, you could employt the second method and have the checks be based on rules you configure through a dynamically loaded file, this way, you could (theoratically) build your middle tier in such a way that you can add new front ends / back ends without having to redo the middle tier. This might eventually be the cleanest / best way to go, but it is also the most difficult and takes a lot of planning beforehand.
    Mark

  • Edit location where iphone4 puts uploaded mobileme video

    I have a lot of photos and videos on my mobileme gallery already, and in various folders. How do I tell my iphone 4 where to put the video that I just shot when I select upload to mobileme? It's currently defaulting to a folder that I don't really want it to go to, but I don't know where to find a place that I can tell it to upload elsewhere. Help...

    The last 2 queries are getting optional data out of the DB.  The user is not required to fill out those fields but if they do, I want to get that data.
    I have designed it this way following the instruction of the book "head first php and my SQL" by Head First Labs.  It said that you should minimize duplicate data in a table as much as possible to keep them small.  Instead put the data in a separate table and reference it with a key.  Your tables should only describe one specific thing, so thats what I did.  I have them linked with foreign keys and primary keys.
    In my case each user can have a vehicle saved for them, maybe 2 or 3.  for each vehicle they have the option of listing a car audio setup for that vehicle.  Now when they change their setup and update it on the site, a new setup entry is made.  That way the old pics/video of their old setup are still correct and all new pics will be correct as well.     So essentially each vehicle can have maybe 5. 10 setups linked to it.   Hence the separate table for video data, vehicle and setup.  make sense?
    As for the joins, I was kind of confused on how to do it correctly with my particular queries. And since the 2nd and 3rd queries dont always need to be executed, i thought if i left it as 3 it might save some execution time as only 1 short query needs to be executed.
    what is your opinion on the matter?
    and what do you mean by procedural language? like if/else?

  • Archiving Design Decisions

    Hi Friends,
    I would like to know the data archiving frequency  & Design decisions for data archiving?
    Thanks in advance,
    Chandu.

    Hi Chandu,
    Frequency depends on nature and residence period of data. Application data like IDOC, Work Items and Application logs has short residence time those can be archive very frequently, whereas business data has long residence time period those can be probably archive annually or Quarterly.
    Archiving Decision depends on business’s legal and technical  retention policies.
    Regards,
    Rajnish Pathak

  • Where to put ASE files

    Once I download the ase files I can't quite figure out where
    to put them so that when I'm using Photoshop or Illustrator or any
    Adobe application they will show up as option for me to select from
    in the swatches palette. Any advice would be appreciated.
    Thanks!

    Thanks for the tip. It was helpful. By doing that I realized
    that I could store the .ase files in the same place Adobe
    Photoshop, Illustrator, In Design, and Go Live currently store the
    swatches.
    I have CS2, and this is where I found the current storage of
    swatches.
    C Drive > Program Files > Adobe > Adobe Photoshop
    CS2 (or Illustrator, In Design, Go Live) > Presets > Color
    Swatches/Swatch Library/Swatches (depending on the app)
    Then I tested each out in that particular application and
    they worked beautifully. The only thing that stinks is that you
    have to put the .ase file in each Swatch folder for each one of the
    applications so in my case that was 4 times. I guess you could keep
    them in one central place and then access them from all
    applications.

  • Where i Put my swing application jar file in jboss

    Hi experts...
    I develope swing application and convert it into jar file....I know jnlp deployment using tomcat..In tomcat i
    put my appcation.jar in webapps/root folder...This is not similar in jboss..I dont know where i put my applcation.jar in jboss.If any body know the idea please let me know..

    Hi
    You have to put your jar file in
    server/default/deploy
    Regards
    M Fazal Ur Rehman

  • I changed my iPhone lately but i can't restore my last backup since it keeps saying "itunes could not restore backup because the password was incorrect" but I don't know where to put the password to make it happen... Any suggestions?

    Hey guys,
    I just bought a new iPhone but i can't restore my backup files beacuse it keeps saying "itunes could not restore backup because the password was incorrect" but I really don't know where to put the password to restore it. I really have some files that are meaningful for me so I really need help. Any suggestions anyone?

    Select your iDevice in the iTunes.
    Choose the Summary screen (tab) and scroll to the bottom of the screen.
    Then un-select Encrypt iPhone backup.
    iTunes will then prompt you to “Enter the password to unlock your iPhone backup”, enter the password you set originally.

  • My computer screen keeps going blank and then going back to the box where I put my password in to start my comp. Why is this happening?

    My computer (Macbook) was working fine this am. I left it for an hour and then came back and the screen was black (always does that as the screensaver hardly ever works). I moved the mouse to wake it up and everything was normal. I went to adjust the volume and the screen went blank and the main page with the box where I put my password in when I first start my comp appeared. I put my password in and everything was normal again. I opened a window in Safari and before it loaded completely the same thing happened, the screen went blank and went back to the password box. Does anyone know why this is happening? I don't have an external hard drive or any blank flash drives so I can't back anything up right now and am afraid I'm going to lose everything. Thank you

    Sounds like hardware failure, called boot loop. Call Apple and or go on apple.com and make Genius Bar appointment to have your iphone reviewed by a Tech. Provided you iphone shows no physical or liquid damage they will take care of you, or if you have Apple Care Plus
    Genius Bar Rerservation :  http://www.apple.com/retail/geniusbar/

Maybe you are looking for

  • Error in @Override while chaning from JDK1.6 to JDk1.5

    Hi, I am getting following error while migrating from JDK1.6 to JDK1.5. Multiple markers at this line      - implements org.quartz.Job.execute      - The method execute(JobExecutionContext) of type TransferFiles must override a superclass      method

  • Displaying Release Date from Atom Feed

    When using an atom feed with iTunesU, we find that the Release Date field does not show meaningful data. The field contains the value of today in every instance. I wonder if there is any way to make Release Date show the contents of the <updated/> el

  • T60 frankenpad

    Hi All I have come accross some brand new T61 penryn boards made after August 2008. It therefore seems quite obvious to me that I should convert two of my T60s to more powerful machines. (already traded my T61 for my wifes T60). I have bought two mot

  • Photo/battery bug

    I have had my iphone 4S for about 2 years. First time this has happened but i got 19% battery and the iphone shutdown and was asking to be plugged. Usallly it does auto shutdown if i get to 2-0%. The thing is i charged it and now i have over 7000 pho

  • Content Presenter CMIS Query. Cache

    Hi!. Is it possible caching CMIS Queries in Content Presenter TaskFlows of WebCenter Portal PS3? Thanks :). Edited by: Daniel Merchán on 03-nov-2011 17:03