SOS!! Simple yes/no question about JPA...

Hello,
I have the following environment and requirements:
-Tomcat 5.5 (no ejb container)
-Latest version of Hibernate
-JSF 1.1
-A requirement to use JPA
-I must use the query cache and the second-level cache
My question is as follows:
What is the best solution?
Solution 1.
ONE EntityManagerFactory stored in the ServletContext for use by all of my web app users generating MULTIPLE INSTANCES of EntityManagers. (would this allow me to use the query cache?)
Solution 2.
ONE EntityManagerFactory and ONE EntityManager stored in the ServletContext for use by all of my web app users.
Thanks in advance,
Julien.

Regarding caching, what exactly are you referring to
by "query cache"? Are you saying you
plan to execute the same query multiple times but
you'd like the underlying persistence manager
to avoid trips to the actual database? Whether the
query is executed by an actual database
access or is fulfilled through some JVM-local cache
is not controlled by the spec. Most implementations
do allow for such caching but the behavior is
persistence-provider specific.Yes. I am actually using hibernate behind the scenes as my persistence framework.
I'd suggest looking at the presentation from last
year's JavaOne called "Persistence In the
Web Tier"
http://developers.sun.com/learning/javaoneonline/2006/
webtier/TS-1887.pdfI am going to have a look at that.
Thanks again.
Julien.

Similar Messages

  • MOD answers please - simple yes / no questions on pops and crackl

    Dear MOD's
    Could someone PLEASE answer these questions with a simple yes / no answer.
    It seems a lot of people are giving up hope on the snap, crackle and pop problem.
    ) Does Creative acknowledge the problem exists?
    2) Have Creative replicated this problem in-house?
    3) Is Creative looking into a fix?
    Considering my X-Fi Fatality is the best of the best of the best, I would expect some info on the situation.
    If its hardware and no software fix will patch it, then at least tell us.
    Leaving so many customers in the dark is just down right rude.
    In anticipation of your quick response
    Bozzy

    It's funny, the mods don't seem to exist when you ask them a question, but if you start swearing up and down these forums, they're on you like a fat kid chasing smarties!!
    Or if there's a new product being launched, they're all over the forums saying, "check out the demo, buy Creative products now!!" Screw that!!! Little do consumers know that when they buy a Creative product, they don't get the support they need. The Audigy beta driver has been in the beta stage for 3 months!!!!!!!!!! 3 freakin' months!! You better hope and pray that when you buy a Creative products, it works out of the box!!!
    Message Edited by Dr_Know on 2-6-2005 06:09 PM

  • [Theory] A simple but hard question about OO programming

    I was in my first class of OO programming (4th year of computer engineering in Valencia) and the professor gave us homework.
    The homework was a simple question about OO programming (it is not about a specific language, though we are going to use Java in the practice sessions), we shall find an answer to it and discuss it in class the next day.
    The question was:
    "May classes also be objects?"
    which can be said as:
    "May classes be instances of an(other) classes?"
    I hope that you, archers, can enlighten me in this question

    tvale wrote:I believe an object is an instance of a class.
    Yup, that's true. Let's see... An object is an instance of a class, so we can have a lot of objects coming from one class.
    We can say an object is not a class because it has a state (think about a light, it has a state: on or off, but a class light is not on/off, because in a class we just describe the behavior that class should have.
    But what we're asking here is if a class can have a state. I think it may refer to static properties about the objects.

  • A Simpler, More Direct Question About Merge Joins

    This thread is related to Merge Joins Should Be Faster and Merge Join but asks a simpler, more direct question:
    Why does merge sort join choose to sort data that is already sorted? Here are some Explain query plans to illustrate my point.
    SQL> EXPLAIN PLAN FOR
      2  SELECT * FROM spoTriples ORDER BY s;
    PLAN_TABLE_OUTPUT
    |   0 | SELECT STATEMENT |              |   998K|    35M|  5311   (1)| 00:01:04|
    |   1 |  INDEX FULL SCAN | PKSPOTRIPLES |   998K|    35M|  5311   (1)| 00:01:04|
    ---------------------------------------------------------------------------------Notice that the plan does not involve a SORT operation. This is because spoTriples is an Index-Organized Table on the primary key index of (s,p,o), which contains all of the columns in the table. This means the table is already sorted on s, which is the column in the ORDER BY clause. The optimizer is taking advantage of the fact that the table is already sorted, which it should.
    Now look at this plan:
    SQL> EXPLAIN PLAN FOR
      2  SELECT /*+ USE_MERGE(t1 t2) */ t1.s, t2.s
      3  FROM spoTriples t1, spoTriples t2
      4  WHERE t1.s = t2.s;
    Explained.
    PLAN_TABLE_OUTPUT
    |   0 | SELECT STATEMENT       |              |    11M|   297M|       | 13019 (6)| 00:02:37 |
    |   1 |  MERGE JOIN            |              |    11M|   297M|       | 13019 (6)| 00:02:37 |
    |   2 |   SORT JOIN            |              |   998K|    12M|    38M|  6389 (4)| 00:01:17 |
    |   3 |    INDEX FAST FULL SCAN| PKSPOTRIPLES |   998K|    12M|       |  1460 (3)| 00:00:18 |
    |*  4 |   SORT JOIN            |              |   998K|    12M|    38M|  6389 (4)| 00:01:17 |
    |   5 |    INDEX FAST FULL SCAN| PKSPOTRIPLES |   998K|    12M|       |  1460 (3)| 00:00:18 |
    Predicate Information (identified by operation id):
       4 - access("T1"."S"="T2"."S")
           filter("T1"."S"="T2"."S")I'm doing a self join on the column by which the table is sorted. I'm using a hint to force a merge join, but despite the data already being sorted, the optimizer insists on sorting each instance of spoTriples before doing the merge join. The sort should be unnecessary for the same reason that it is unnecessary in the case with the ORDER BY above.
    Is there anyway to make Oracle be aware of and take advantage of the fact that it doesn't have to sort this data before merge joining it?

    Licensing questions are best addressed by visiting the Oracle store, or contacting a salesrep in your area
    But I doubt you can redistribute the product if you aren't licensed yourself.
    Question 3 and 4 have obvious answers
    3: Even if you could this is illegal
    4: if tnsping is not included in the client, tnsping is not included in the client, and there will be no replacement.
    Tnsping only establishes whether a listener is running and shouldn't be called from an application
    Sybrand Bakker
    Senior Oracle DBA

  • Toplink question about JPA/EJB3

    Hi chers ;)
    When you create a new entity, an associantion has a "list" of associed item, like this:
    @OneToMany(cascade={CascadeType.PERSIST}, mappedBy = "trecho")
    private List<CidadeTrecho> cidadeTrechoList;
    When I call the method trecho.getCidadeTrechoList(), Toplink will do a simple automatic select in database to get all objects associated with this object (in that scene, will get all CidadeTrecho who's has a associatin with this trecho)
    Toplink fine's console will output things like this:
    TopLink Fine]: 2007.01.22 05:43:57.875--ServerSession(9261456)--Connection(28205253)--Thread(Thread[HTTPThreadGroup-5,5,HTTPThreadGroup])--SELECT IDCIDADETRECHO, ORDEM, CD_TRECHO, CD_PAIS, CD_ESTADO, CD_CIDADE FROM RODO_CIDADETRECHO WHERE (CD_TRECHO = ?)
         bind => [101]
    My questions is: Have a mode to change this select query to find the list of associations? I want change only a little thing, I want only add a "order by" statement at end of thist query.
    Anybody can help me?
    Reggards

    You can add an @OrderBy annotation to control the select.
    @OneToMany(cascade={CascadeType.PERSIST}, mappedBy = "trecho")
    @OrderBy("foo ASC")
    private List<CidadeTrecho> cidadeTrechoList;--Shaun                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Some important question about JPA!!!

    Hi there, I have a web application written in Java 1.4
    I want to move this to Java 1.5 using JPA but after review old code I've got some stuck:
    1. This application have a function that get Lists from a table:
    Collection getList(String className, string tableName)
    That do follwing tasks:
    Get set of properties from class schema (by className)
    Get record set from table
    Each row of record set do:
    - Create object and set properties value from column that named the same name of property.
    - Add object to collection
    Return collection
    As my knowledge, in JPA, each entity class schema is mapped with a table schema. So, this function can't migrate. But in my application case, there are about 50 tables, mapping entities to each table is not good idea. Is there another solution?
    2. In database design, a table have composite PKs that merge from many part, each part is a property of entity too, for example table User have column User_ID = Agency_ID + Deparment_ID + SeqNum. How I can map Agency and Department properties of User entity to the table User?
    Please help me, thanks
    Thank you.

    Hi uvnet,
    I think the old code can run in java 1.5 with a minor change but the problem is I want take advantage of using 1.5 especially JPA (big change :D ).
    Anyway, the sample code would be:
    import java.sql.ResultSet;
    import java.util.ArrayList;
    import java.util.Collection;
    import java.util.Iterator;
    import java.util.Map;
    import org.apache.commons.beanutils.BeanUtils;
    import org.apache.commons.beanutils.PropertyUtils;
    public class DAO {
         public Collection getList(String className, String tableName, int encoding) {
              Object objDescriber = null;          
              ResultSet rs = null;
              Map map = null;
              Iterator properties = null;
              ArrayList<Object> returnValue = new ArrayList<Object>();
              try {
                   objDescriber = (Object)Class.forName(className).newInstance();
                   try {
                        map = BeanUtils.describe(objDescriber);
                        properties = map.keySet().iterator();
                        //Get ResultSet from Table
                        rs = getResultSet(tableName);
                        while (rs.next()) {
                             while (properties.hasNext()) {
                                  String name = (String) properties.next();
                                  String typeName = PropertyUtils.getPropertyType(objDescriber, name).getName();
                                  //Get value from current row and column name of ResultSet
                                  Object value = getValue(rs, name, encoding);
                                  try {
                                       Object obj = (Object)Class.forName(className).newInstance();
                                       PropertyUtils.setProperty(obj, typeName, value);
                                       returnValue.add(obj);
                                  catch (Exception ex) {
                   catch (Exception ex) {
              catch (Exception ex) {
              return returnValue;
    }

  • Very simple and quick question about Arrays

    Hi,
    I have the following code to produce a student grades provessing system. I have got it to store data in the array, i just cant figure out how to add the integers from the row to produce a total. Thats all I want to do create a total from the 6 marks and add a percentage.
    Any help would be greatly appreciated.
    -------------CODE BELOW----------------------
    import java.util.*;
    public class newstudent1_2
    public static void main (String[]args)
    System.out.println ("-----------------------------------------------"); //Decorative border to make the welcome message stand out
    System.out.println (" Welcome to Student Exam Mark Software 1.2"); //Simple welcome message
    System.out.println ("-----------------------------------------------");
    int [][] mark;
    int total_mark;
    int num_students;
    int num_questions = 9;
    Scanner kybd = new Scanner(System.in);
    System.out.println("How many students?");
    num_students =kybd.nextInt();
    mark = new int[num_students][num_questions] ;
    for (int i=0; i<num_students; i++)
    System.out.println("Enter the Students ID");
    String student_id;
    student_id =kybd.next();
    System.out.println("Student "+i);
    for( int j=1; j<num_questions; j++)
    System.out.println("Please enter a mark for question "+j);
    mark[i][j]=kybd.nextInt();
    System.out.print("id mark1 mark2 mark3 mark4 mark5 mark6 mark7 mark8");
    //This section prints the array data into a table
    System.out.println();
    for (int i=0; i<num_students; i++)
    for( int j=0; j<num_questions; j++)
    System.out.print(mark[i][j]+"\t"); //the \t is used to add spaces inbetween the output table
    System.out.println();
    --------------END OF CODE---------------
    Thanks.

    I had to do this same sort of thing for a school assignment but i didnt use an array.
    import java.text.DecimalFormat;
    import TurtleGraphics.KeyboardReader;
    public class grade_avg
         public static void main(String[] args)
              int grade, total = 0, count = 0;
              double avg = 0.0;
              KeyboardReader reader = new KeyboardReader();
              DecimalFormat df = new DecimalFormat("0.00");
         for (;;)
                   grade = reader.readInt("Please enter a grade: ");
              if (grade > 0)
                        total = total + grade;
                        count ++;
              if (grade == 0)
                        avg = total / count;
                        System.out.println("The average is: " + df.format(avg));
                        System.exit(0);
    }output looks like:
    Please enter a grade: 100
    Please enter a grade: 50
    Please enter a grade: 0
    The average is: 75.00

  • Simple (probably dumb) question about Mail --

    After I read a message, how do I go the next message without closing the current message box and going back to Inbox? That is, is it possible to read a message then go to the next one, then the next one, etc. without going back to the Inbox?
    Thanks for any help.
    Sunil

    you can read a message from the message list, by reading in the preview pane. if you do not have the preview pane set on your main window, go to the bottom of the window, you will notice a line with a dot at the middle, drag that dot to the middle of the window or a little higher and drop it. you should now have your main window divided in two, with the upper part showing the message list, and the lower part showing the text of the email you have selected in the message list.
    hope this helps

  • Really simple Mac Mail question about the Delete button

    When at a message, the Edit menu shows Command+Delete as being the proper keystroke for deleting a message.
    Just pressing Delete also removes it from the Inbox.
    What is different between that and Command+Delete?
    Thanks,
    doug

    Hi,
    I don't have a very good answer to you other than the fact that the Macbook does not have a proper DELETE-button.  You delete by pressing cmd/backspace.
    If you want to delete something through Finder you have to press cmd/backspace.  In orher programs, like Mail, you can delete by pressing only backspace.  In iPhoto you can delete pictures by presing backspace and conform with return.
    The reason for these different solutins are not known to me...  
    Nils

  • Question about PNP...LDB

    Hi All,
    I have been asked a simple but strange question about PNP LDB. When we assigned logical database in our program, it will basically create a selection screen, which have certain fields. Like Today.. Some date ranges. Person assigned number, company code, company status.
    From my standpoint I know when ever we give selection to PNP screen we have to check this selection parameters in our programs, like date range ,person number, employee status etc ….RIGHT?
    Somebody ask me that without checking selection in our report I mean any parameters, it can filter the record, my Answer was BIG “NO”. You need to check all the parameters in your program.
    Next question asked by me was what the purpose of PNP. I replied that rather then declaring and doing bunch of databases SAP provide logical database so current all the records and do what ever you like to do.
    What you think guys?
    Thanks

    Here`s the question , when I am giving "1"active employee in employee status why its pulling up the information for '0' withdrawn employee?
    Message was edited by: Saquib Khan

  • Yet another question about super raid - GS70

    Yes, another question about Super Raid...I recently picked up the cheapest model of the GS70 on newegg which comes with 1 mSata SSD...just a mediocre one if I remember reading correctly.  I'm interested in using MSI's Super Raid once my warranty is over with and have been reading a couple posts here:
    1. Walk through of how to reinstall OS
    --> https://forum-en.msi.com/index.php?topic=167198.msg1224063#msg1224063
    2. I'll need a Super Raid card with links to get some, for about $100 each
    --> https://forum-en.msi.com/index.php?topic=171722.msg1252847#msg1252847
    3. I can't get Super Raid unless it originally came with it?
    --> https://forum-en.msi.com/index.php?topic=171185.msg1249640#msg1249640
    So what's the bottom line? Would I still be able to enable super raid in the future or am I SOL since it didn't come with it originally?
    thanks!

    The GT70 CAN come with an adapter that has 2 (on the older, GT70 0NX models) or 3 (on newer GT70 20X models) sockets for mSATA drives. It's an optional part, that takes place of the primary SATA drive in the notebook, and physically has a different part that connects to the motherboard. If it doesn't come with the SuperRaid adapter, then it just has support for a single 2.5" SATA drive.
    The GS70 on the otherhand, has this built into the motherboard and there is no swapping it out for a normal 2.5" SATA drive. You can only use mSATA drives (on those ports). The GS70 is meant to be an ultrabook, and therefore does not have the same ability as the GT70 to house up to 2 full size 2.5" SATA drives.
    That's really the main difference here. Without physically seeing a GT70 to see how the SuperRaid adapter works, it's slightly difficult to explain.
    But in the end, I wouldn't worry about the SuperRaid....The GS70 should have support for Intel Raid Management Engine, in which case that's all you really need.

  • Two weird questions about BP maintenance......SOS!!!

    Two weird questions about BP maintenance......SOS!!!  
    The procedure is like this:
    These informtion will be import to SAP:
    BP information
    Address Information of this bp.
    Communication information of this BP
    1. check if the bp exist, if yes, update the BP.Then go to 3.if no go to 2
    2. Create a bp with the Address information and communication information
    3. Check if the Address information has been existed,if yes go to 4.else go to 5
    4.Update the address information with the communication information.
    5.Create a new address for this BP.
    And the problem I got is like this:
    1. After I changed the BP information, such as the surname,lastname etc.Use this BAPI
    "BAPI_BUPA_CENTRAL_CHANGE",I commited it.Then I call the BAPI "BAPI_BUPA_ADDRESS_CHANGE" to change the Address of this BP,however
    When I call the BAPI_BUPA_ADDRESS_CHANGE,it always told me the BP is locked by myself.............
    I am sure I do not open the BP in the other window.And I commit it after I call the BP Change BAPI.
    2. When I change the communication information ,it always told me BAPIADTEL you want to update does not exist in this system.....I am sure it does.
    Who can help me??
    Thanks very much

    Hi,
    1) Problem with the lock. To commit the changes after the BAPI_BUPA_CENTRAL_CHANGE API, instead of using commit work to commit, Use BAPI_TRANSACTION_COMMIT. This should solve the problem. This wil help in clearng the buffers of BP.
    2) in the BUPA_ADDRESS_CHANGE, for telephone there are two parameters to be filled IT_ADTEL, IT_ADTEL_X
    IT_ADTEL : Should be filled with the telephone details etc (Consnumber should not be filled for inserts. This should be filled only for updates).
    Corresponding IT_ADTEL_X structure has to be filled with update flag as 'I', 'U' or 'D' based on the task.
    Hope this helps. Let me know if some more info is needed.
    Regards,
    Sudheer.

  • A very simple question about WF

    hi experts
    I would like to ask a question about workflow
    as u may know there is 'Loop' step in workflow, but I am confused when should I use Loop?
    Is this step used for processing internal table?  if yes, why shouldn't I create a custom BOR method and pass the entire internal table to the method?
    many thanks

    hi
    loop step for not process the internal table,
    this is used to process the some steps repetely until condition True or False.
    we have two loop steps is there
    WHILE AND UNTIL.
    Thanks
    sitaram

  • Simple question about mount and delay script

    Hello, I have a simple question about mounting volumes on start up.
    My computer wakes up auto - and then auto there are serveral applescript tasks (mount and start up programs)
    I use this script (daily) for serveral connections with external volumes I always need the connect to. ( In the script I use this code 3 times for other locations) I do this on start up.
    set Uname to "XXX"
    set Pword to "XXX"
    set someVolume to "afp://XXX.XXX.XXX.XXX/XXX/XXX
    mount volume someVolume as user name Uname with password Pword
    (same code for 2 other locations)
    When i do this on start up sometimes the script says there is no connection possible. I guess it's because on start up the connection isn't there. And 1 minute later when computer is total ready the connection is ok. When I run the script then It works. Just sometimes ( In the morning) 'It' want to connect but the script stops. When i do it manually(I run the script again) it works just fine.
    Is it possible that I need a delay? Can someone explain this?
    How would I make a delay handler for this script? Is that the best solution?
    Thanks in advance. This is something small i'm wondering about.
    Colin

    BTW, If you saved the script as an application +(and not as an application bundle)+ you could drop the script on to *Drop Script Backgrounder* (freeware).
    Then the script would run in the background, so, you wouldn't see it running in the Finder.
    <http://www.macupdate.com/info.php/id/7922/drop-script-backgrounder-x>
    Tom

  • A simple question about combo box

    Dear All,
    Just got a simple question about combo box: I have one of these selectors with labels based on filtered rows from a table.
    Is it possible to have one more label that would select all options?
    Like:
    Product A
    Product B
    Product C
    All Product
    Many thanks for your help!
    Gilles

    Hi Gilles,
    The purpose of ComboBox itself to select single option out of many.
    For your purpose, you may have to use "List Builder" which can accomodate 1 or more  to select.
    Please revert for more clarification if you need.
    With best wishes
    BaaRaa.

Maybe you are looking for