Setting session variables in application context using OpenJPA

Hi!
I am using openjpa 1.2 with EJB 3.0. I am connecting to Oracle 11g database and need to use the oracle virtual private database for security and data segregation. For this purpose, I need to set some custom variables at the session level of the application context such as the application user name. Since, I am using container injected EntityManager using @PersistenceContext, I am finding it hard to do so.
Can anyone please help me out
Thanks in advance
Abhi

You will probably want to ask your question on an OpenJPA forum to see if they even can support VPD (if not, see EclipseLink http://wiki.eclipse.org/Introduction_to_EclipseLink_Sessions_(ELUG)#Isolated_Client_Sessions_and_Oracle_Virtual_Private_Database_.28VPD.29 )
You might also want to try injecting the factory instead and use that to get the EntityManager instead of injecting the em directly. ie
@PersistenceUnit(unitName="my-pu")
private EntityManagerFactory emf;
Best Regards,
Chris

Similar Messages

  • 'In Between' Date Prompt to set Session Variables???

    Hi
    Im very new to OBIEE and was hoping someone could help me. I have a date prompt using the 'in between' operator based on a date column.
    I am trying to set up a table in the Physical layer of the RPD using a stored proc (EXEC sp_name). The stored proc takes 2 input paramaters - a start data and an end date. These dates i would like to come from the in between prompt. I have set up the physical table structure to receive the results of the request.
    I looked at setting a session variable but it is asking me to insert sql to set the value and i dont want to hit the database outside of the stored proc. Also, even if i have session variables i cant see how to set them to the values in the prompt when using the 'In Between' operator.
    Im really very confused and i have been searching the net and the documentation for any clue.
    Any help would be appreciated
    Thanks

    In between operator doesn't support presentation variable..
    so break this into is into two prompts...and use equal to operator, then you can use them as request variables which will in turn override your session variables.
    in the report use operator between and use these variables in the filter..

  • Set session variables inside a page

    Inside the page "form.cfm" I have this code:
    <form name="report" action="pagestatistic.cfm"
    method="post">
    <INPUT name=ONE size=15 >
    <INPUT name=TWO size=15 >
    <input type="submit" value="Go ON">
    </form>
    I would like to set session variable: ONE and TWO, inside the
    page: pagestatistic.cfm
    IN that way when I will refresh the page "pagestatistic.cfm"
    I will watch have the same results.
    I added this code at the top of "pagestatistic.cfm" but it
    doesn't work.
    <CFSET session.ONE = #ONE#>
    <CFSET session.TWO = #TWO#>
    Could you tell me what goes wrong?
    Thanks
    CFWork

    quote:
    Originally posted by:
    liquid One
    When you say refresh the page, do you mean submit the form by
    clicking on the submit button? Or are you filling out the input
    boxes and hitting refresh?
    I mean I clicked a link that links the same page:
    pagestatistic.cfm
    Then I would like to add to this link 2 get variables
    pagestatistic.cfm?ColorPage=Green&Order=2 to change the
    background color and the order of the results of the page. That it
    is impossible because when i refresh the page it is doesn't work.
    What do you suggest me to do?
    Thanks,
    CfWork

  • Application.cfm - Should I use queries or set session variables?

    Hi,
    I have an application that has many users for many different
    companies logged in at the same time using the system. I use the
    application.cfm to call and set a bunch of variables that make the
    system work, such as preferences and things. Would it be better to
    use 5 or 6 queries all pulling one record, or call the queries only
    once at the start of the session and set 30 to 50 session variables
    based on the query results? Which method would bog the system down
    less? It seems that session variables use quite a bit of memory.
    I'm just trying to get the "simple answer" for this, if that's even
    possible.
    Please let me know your thoughts and experience on this.
    Thanks much,
    Jeff W!

    In order to give you a simple "do it this way" answer, more
    information is needed.
    How long does it take to run those 5-6 queries on each
    request? How many users are logged in at peak times? How much data
    would you be storing in the session for each user? How much RAM do
    you have on your server?
    On one application, we've decided to go the session variable
    route. The size for each users' session maxes out at 2.5 KB. We
    have 512 MB dedicated to CF, but can easily scale up on the
    hardware we have to 1.5 GB or more. At 512 MB, 2.5 KB per user
    session, we can handle a little over 200,000 concurrent users
    (assuming all CF memory could be utilized for session variables,
    which isn't true). There are only 6,000 users total in our system,
    so we have quite a bit of headroom.
    Are you on CF8? If so, open up the server monitor, start
    monitoring, profiling, and memory tracking, and log in with a
    couple users (with your code setup to store all that info in the
    session). See how much storage each session takes. Then look at
    your server. How much RAM do you have? what do you currently have
    allocated to ColdFusion? What's your peak concurrent user level? Do
    you have headroom? Also, see if the benefits of storing it in the
    session are even worth it (how long do those 5-6 queries add to
    each requst?)

  • How to set the value of application item using pl/sql in application process

    Hi guys,
    I want a global variable (application item) whose value will be set at the start when a user logs in to the application. The value will be retrieved from database using a sql query. I do not know the exact syntax to set the value of application item in application process. Also i want to know in which type of application process should i use to set the value of application item when a user starts a session. The value of application item varies from user to user.
    Please help.
    I am using apex 4.2
    Regards,
    Waqas

    You can use the application item as bind-variable with its name. ie. your application item is named G_MY_APPLICATION_ITEM, then you can access/set it using :G_MY_APPLICATION_ITEM.
    For example
    BEGIN
        -- assign like a variable
        :G_MY_APPLICATION_ITEM := 'LARRY';
        -- use in a SQL statement
        SELECT WHATEVER_COLUMN
          INTO :G_MY_APPLICATION_ITEM
          FROM MY_TABLE
         WHERE USERNAME = :APP_USER
    END;
    Peter

  • Set Session Variable

    Hello,
    Anyone know how to set a session variable from data entered within a messageTextInput field from a uix page within a JHeadstart application?
    I tried to trigger an event to write the session but was unsuccessful.
    Any ideas?
    -Jeff

    Jeff,
    We do not support UIX events, because they are part of the UIX Controller. We use the Oracle9iAS MVC Framework (or Struts in next release) as the Controller.
    So, if you want to put a value of a messageTextInput on the session, you need to write a custom process that does this. Note that the MVC Framework provides an abstraction called the InfoTable around the Session object.
    In chapter 2 of the JHeadstart User Guide, section "Writing a Custom Process" you can find more information on reading and writing information from/to the InfoTable.
    Steven Davelaar,
    JHeadstart Team.

  • Best Practice for setting bind variable when application loads

    I am using JDeveloper 11.1.2.3.
    When my application loads, the first unbounded page has a table populated by a named query.
    I would like to set the parameter used by the named query when the page loads, to populate the initial data that is displayed.
    What is the best practice for a solution to this issue?

    user6003393 wrote:
    I am using JDeveloper 11.1.2.3.
    When my application loads, the first unbounded page has a table populated by a named query.
    I would like to set the parameter used by the named query when the page loads, to populate the initial data that is displayed.
    What is the best practice for a solution to this issue?Hi,
    You can set the bind variable on VO by overriding prepareSession() method in Application Module check this http://docs.oracle.com/cd/E37975_01/web.111240/e16182/bcservices.htm#sthref357
    Setting bind variable on runtime http://docs.oracle.com/cd/E37975_01/web.111240/e16182/bcquerying.htm#CHDECJHD
    Zeeshan

  • Can I set session variables from inside my Javascript?

    hi all,
    i want to set a couple of session variable while i am inside my javascript.
    can I do that?
    m_asu

    No. JavaScript runs on the client and the session is on the server. You can use JavaScript to set parameters that get passed back in the request and can then be put in the session.

  • Session Variables to control Datasource used by iBots

    Hello everyone,
    i'd like to know whether it is possible to control the session which is used by iBots.
    What i want to achieve is, that i can start an iBot within a certain session with given parameters, based on session variables.
    I have one SessionVariable "sDB" which can be set to =1 or =2. This is controled via the URL used to start OBIEE.
    Now i want to control my ibots by forcing them to start with sDB=1 or sDB=2 etc.
    Does anybody know a solution. Any hint might help aswell.
    Thanks!

    Thank you David for the response. As you guessed, I'm fairly new with session variables. What I'm looking for is as follows-
    On my Architecture website, I have an html form where clients would enter their design preferences and Submit. The website then sends an email to the client with the details they had entered; for confirmation. This had worked properly with form variables as the email is sent right after the form is filled.
    However, now I have added a License agreement page and a second form with other design details, which has to be filled in before the client's email is sent. So, I've set the Page1 form variables as session variables to carry over to the 4th page where it is sent as email. I am able to retrieve the session variables on the fourth page, but what I require is the correct syntax for using it in the subject field and the message body of the email, so that the clients get them in their email.
    I had earlier used the following php code for sending emails using form variables-
        $to="From: $email";
        $subject="$name, Thank you for visiting our website.";
        $from="[email protected]";
        $msg="Your Reg. details-\r\n\n$name\r\n$address\r\n\nPhone No: $phone \r\nE mail: $email \r\n\nMessage:\n$message";
        $fla=mail($to,$subject,$msg,$from);
    ; where the form variables are- $name, $address, $phone, $email, $message
    I have now set them as session variables-
    <?php
    session_start();
    $_SESSION['name'] = $name;
    $_SESSION['address'] = $address;
    $_SESSION['phone'] = $phone;
    $_SESSION['email'] = $email;
    $_SESSION['message'] = $message;
    ?>
    ; and I'm being able to retrieve them on the 4th subsequent page. As mentioned, what I am looking for is the correct syntax to use this data in a php email code.
    I will be very grateful if you could provide me with a sample php email code for sending an email with session variables in the 'from', 'to', 'subject' and 'message' fields.

  • Terminal Command, how to set defaults write, make application(s) use directory path where file last saved?

    Does anyone know whether there's a terminal command to make all applications remember/use the last directory/path where I last saved a file?
    For example, let's say there are (10) ten PDF's on a website, and I want to use Preview.app to open and save each file to the same directory.
    Problem is, after each time I save a file, Preview.app doesn't automatically remember/use the last directory where I saved my file(s).
    Forcing me to navigate back to the same directory after each time I save a file; super-annoying.
    But, for some reason, when saving images from the web, Firefox remembers the last directory where I saved the file (jpeg).
    So I'm hoping there's some way, possibly a terminal command to set/force all applications (including Preview.app) to remember/use the directory/path where file(s) were last-saved.
    Anyone?

    Get the third-party utility Default Folder X 4.4.9.

  • How to re-set session variables in OCI when a TAF callback  is invoked ?

    Can you show me an example of how to re-set NLS_DATE_FORMAT when the Failover ends ( that is, in OCI_FO_END )? All I see is the template code provided by Oracle to handle TAF event.
    How to register TAF callback function

    You can re-set the variable just like you set it at the beginning of the connection in the switch branch you mentioned.
    Doesn't it work?

  • Package variable versus application context variables

    Any difference in using package level variables versus setting attribute value pairs in a session based context ?
    Thanks

    Packaged variable - can be used only by user having execute privilege on the package. Same user can modify the values of the packaged variable when logged on to the session.
    Context variable - It cannot be set by only mere value assignment, It needs to the call to a procedure(trusted program) to set the value, hence it is more secure.
    Both are global variables & can be accessed throughout the session.
    Regards,

  • Setting session variable names based on variables in a loop

    I am trying to set up a loop that sets up a list of variables based upon a list, by looping over the list and setting the session.NAME:
    <CFLOOP list="#fieldnames#" index="fieldname">
    <cfset session.#fieldname# = "1">
    </CFLOOP>
    It does not seem to like session.A_CF_VARIABLE . so session.#fieldname# does not work, I get an error
    A CFML variable name cannot end with a "." character.
    The variable session. ends with a "." character. You must supply an additional structure key or delete the "." character.
    Do I have to wrap it a different way?
    Thanks
    Mark

    ahh. great. that fixed the loop problem. My second problem now appears that I am not picking up the correct data.
    My test data has a form post with field names EMAIL and GENDER, and then I was trying to write session.email = VALUE_OF_FORM_FOR_EMAIL .. session.gender = VALUE_OF_FORM_FOR_GENDER, but what I am actually doing is writing the values EMAIL and GENDER into the session. so session.email has the value EMAIL.. and not what I typed into the form.
    I guess it's because the fieldname in the index is also used as the name in the form and it's confusing it, so it goes for the wrong one, not the value from the form.
    the alternative would be to append something to the name of each field in the form.. so email is F_email and F_gender... although i tried this and using <CFSET session[fieldname] = "F_#fieldname"> but that threw an error, maybe just a formatting issue. I'd prefer to try and make it work without appending anything to the form names
    Here's some test code that has the form fields hard coded -->
    <CFSET fieldnames="email,gender">
    <CFSET email = "[email protected]">
    <CFSET gender = "M">
    <CFLOOP list="#fieldnames#" index="fieldname">
    <cfset session[fieldname] = '#fieldname#'>
    </CFLOOP>
    Thanks once again for the help
    Mark

  • Set Session Variables

    Is it possible to set 'OS_USER','TERMINAL' or 'HOST' in 'USERENV' in C#?
    This assignment is possible to do as in the example code in java.
    Link: https://community.oracle.com/thread/258126

    See http://msdn.microsoft.com/en-us/library/96xafkes(v=vs.110).aspx for details
    Environment.SetEnvironmentVariable("MyVariable", "MyValue", EnvironmentVariableTarget.User);

  • Can I set a Session Variable from a Dashboard Prompt, using values that are

    Hi All
    Trying to set a Session Variable to an integer value, by letting users select a text value from the drop-down list on a Dashboard Prompt. The goal is to set the input parameter to the IndexCol function, but to provide the end users with a text description of what they are setting.
    Select Value Set Variable Value
    My 0
    My Team 1
    My Companies 2
    My Teams Companies 3
    Any suggestions on how to accomplish this? Certainly we could populate the drop-down from a data source, however I don't see how to populate a variable with something other than the values on the screen.
    The IndexCol function is referenced in a Filter in Answers, and I'm thinking to populate a Session variable using the (Presentation) variable value set from the prompt. But how to do this? I see a reference to a function NQSSetSessionValue(), but cannot find documentation on how it works.
    Any clue will be greatly appreciated.
    Thanks

    Hi kishore..
    Looks like the link u have sent uses advanced SQL tab to set session variables. I want to know if I can use "set variable NQ_SESSION.myvar= @something" in the "SQL results" -while creating a dashboard prompt-.
    Purpose: I want the session variable to be set based on whatever report that im currently in.
    And i dont want to use presentation variables because im using a reset button in my page.
    My reset script resets presentation variables and NOT session variables.
    Thanks in advance
    Loy

Maybe you are looking for