Hibernate-JSF session.get problem

Hello,
I use Hibernate+JSF.
I open Hibernate session for each request and close it when the request is finished.
For each logged user I keep userId, companyId and several more Ids.
I have a userSession instance containing this data as well as several methods to get Hibernate objects related with user. For example, in order to get company object:
  public Company getActiveCompany()
    CompanyDAO companyDAO = new CompanyDAO();
    Company activeCompany = companyDAO.getCompany(activeCompanyId);
    return activeCompany;
  }The problem is araised in screen in which I show companies data.
It seems like Hibernate has a problem of loading the same object more than once.
For example, in Companies screen, the active company of a User is shown as well as a dropdown filled with companies. The dropdown has a converter named: CompanyConverter which returns a Company object for a given company id.
When switching Company on the dropdown a "valueChangeActiveCompany" event is triggered and the new selected Company should be set to the User. The problem is that the Company object was already loaded to show the active Company on the top of the screen, and the data that is extracted from the converter seems to be empty . . .
The code of the valueChanged is:
  public void valueChangeActiveCompany(ValueChangeEvent event)
    activeCompany = (Company)event.getNewValue();  // Here the object is empty . . . 
    log.info("Setting new Active Company: " + activeCompany +
                                        " for user: " + userSession.getUser());   
    try
      userSession.setActiveCompany(activeCompany);
    catch (HibernateException ex)
      FacesUtil.addErrorMessage("setup.company.view.error.changeCompany");
  }  This problem causes the value of the new active company not to be set, therefore it is not possible to switch between active Companies . . .
Why Hibernate behaves weird when loading an object for the second time on the same session ?
Is there a good way of solving this problem ?
Guy.

hi
i had similar problem.
i solved it but i dont know whether its the correct solution.
i placed the magaed bean in the session scope
in the first page i add a new variable and stored that value in the avtionlistener method. when i click on back button in the 3rd page i get the value which i stored in the first page and display the data.
i hope this is ur problem. if this is the problem let me know i can send u the code snippet
thnaks
sreedevi

Similar Messages

  • Hibernate 3.0 Configuration Problem

    Dear friends,
    I tried to test Hibernate 3.0 via a simple example. But I met strange problems.
    In my Main.java, I put
              Configuration cfg = new Configuration();
              cfg.addClass(hb.Keyword.class);
              cfg.addClass(hb.KeySet.class);
              cfg.configure("/hibernate.cfg.xml");
              SessionFactory sessions = cfg.buildSessionFactory();
              Session session = sessions.openSession();
    Then whatever the content of "hibernate.cfg.xml", there is no parsing error. In log file, it is always,
    09:18:56,328 ERROR SchemaUpdate:129 - could not get database metadata
    It seems the configuration file is nerver really parsed.
    What king of missing details could cause this?
    Thanks.
    Pengyou
    PS:
    09:35:31,859 ERROR SchemaUpdate:129 - could not get database metadata
    java.sql.SQLException: Table not found in statement [select sequence_name from system_sequences]
         at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
         at org.hsqldb.jdbc.jdbcStatement.fetchResult(Unknown Source)
         at org.hsqldb.jdbc.jdbcStatement.executeQuery(Unknown Source)
         at org.hibernate.tool.hbm2ddl.DatabaseMetadata.initSequences(DatabaseMetadata.java:113)
         at org.hibernate.tool.hbm2ddl.DatabaseMetadata.<init>(DatabaseMetadata.java:39)
         at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:124)
         at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:265)
         at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005)
         at Main.main(Main.java:29)
    09:35:31,859 ERROR SchemaUpdate:158 - could not complete schema update
    java.sql.SQLException: Table not found in statement [select sequence_name from system_sequences]
         at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
         at org.hsqldb.jdbc.jdbcStatement.fetchResult(Unknown Source)
         at org.hsqldb.jdbc.jdbcStatement.executeQuery(Unknown Source)
         at org.hibernate.tool.hbm2ddl.DatabaseMetadata.initSequences(DatabaseMetadata.java:113)
         at org.hibernate.tool.hbm2ddl.DatabaseMetadata.<init>(DatabaseMetadata.java:39)
         at org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:124)
         at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:265)
         at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005)
         at Main.main(Main.java:29)
    hibernate.cfg.xml contents:
    <?xml version='1.0' encoding='utf-8'?>
    <!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
    <hibernate-configuration>
    <session-factory>
    <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
    <property name="hibernate.connection.url">jdbc:hsqldb:db/test</property>
    <property name="hibernate.connection.username">sa</property>
    <property name="hibernate.connection.password"></property>
    <property name="dialect">org.hibernate.dialect.HSQLDialect</property>
    <property name="show_sql">true</property>
    <property name="transaction.factory_class">
    org.hibernate.transaction.JDBCTransactionFactory
    </property>
    <property name="hibernate.cache.provider_class">
    org.hibernate.cache.HashtableCacheProvider
    </property>
    <property name="hibernate.hbm2ddl.auto">update</property>
    <mapping resource="hb/KeySet.hbm.xml"/>
    <mapping resource="hb/Keyword.hbm.xml"/>
    </session-factory>
    </hibernate-configuration>

    Thanks.
    But then it gave the following exception:
    11:05:08,390 WARN SettingsFactory:103 - Could not obtain connection metadata
    java.sql.SQLException: File input/output error: java.io.IOException: The filename, directory name, or volume label syntax is incorrect
         at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
         at org.hsqldb.jdbc.jdbcConnection.<init>(Unknown Source)
         at org.hsqldb.jdbcDriver.getConnection(Unknown Source)
         at org.hsqldb.jdbcDriver.connect(Unknown Source)
         at java.sql.DriverManager.getConnection(DriverManager.java:525)
         at java.sql.DriverManager.getConnection(DriverManager.java:140)
         at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
         at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:72)
         at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1463)
         at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1004)
         at Main.main(Main.java:29)
    11:05:08,609 WARN Configurator:126 - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/C:/Java/hibernate-3.0/lib/ehcache-1.1.jar!/ehcache-failsafe.xml
    11:05:09,015 WARN JDBCExceptionReporter:71 - SQL Error: -29, SQLState: S1000
    11:05:09,015 ERROR JDBCExceptionReporter:72 - File input/output error: java.io.IOException: The filename, directory name, or volume label syntax is incorrect

  • JSF session length - how to set? ViewExpiredException - how to avoid?

    Hi! Is there something like JSF session? If yes, how can I set its length so that ViewExpiredException is not being thrown so fast? After I restart my server, httpSession in my browser still exists, but ViewExpiredException is thrown. Is there a way to eliminate completly this exception from JSF application??? PLEASE HELP!

    cocolino81 wrote:
    Thanks for help. The problem is also that <session-timeout> is for example 1 hour and I get ViewExpiredException after 15 minutes!This was because you restarted the server or redeployed the application, is it? Besides, this would also occur if you use an IDE and are still actively developing the webapp. Tomcat will redeploy automatically on every change of one of the deployed files.
    If you read this, please write how do you deal with this excpetion. I would really like to know all your solutions. Thanks in advance.Depends on the purpose of the application. If the user have to be logged in, then I would just set a clear and user-friendly error-page which informs the user that the session has expired and that the user has to re-login. If there is no means of a login but the user just have to enter and submit a form, I would rather keep the session alive using ajaxical polls from the form on. If there is even no means of a form and you used commandlinks/buttons and navigation cases for navigation, then I would get rid of that way of navigation and just use outputlinks for navigation.

  • Firefox gets problems when 2,7 GB of memory is used by Firefox

    Firefox gets problems when 2,7 GB of memory is used by Firefox. Or more. Like 2,8 GB.
    It started when I read jpost.com with tens of tabs open. I don't remember how many. But I know there was more than 40.
    On the tab I that I was reading, the page turned completely black. Pitch black with nothing else, not even the Firefox interface. It was actually a pitch black shape that looked like a web page in shape. The blackness quickly disappeared and the page was normally readable again. But then it happened again - the page turned black again.
    The same page turns black happened again later.
    One of my browsing sessions had Firefox slow down so much that you could see scrolling happening when I used scrolling.
    Still another time I had 60 tabs open and Firefox worked completely fine without freezes, slowdowns, or black shapes. I could close Firefox by just pressing the red X in the title bar.
    Yesterday, I had 50 tabs open and I experienced a slowdown when I looked at the Breaking News headlines. The headlines would show slower than usual. The Breaking News headlines at jpost.com show the headlines a few words at a time until the headline is completely shown. Then the headline disappears and the next starts showing a few words at a time. And speed in general was not what you normally have with a computer that has 8 GB of memory. And a Core i5 processor. I opened two more tabs from the Breaking News section I had opened. After I opened a new window, Firefox froze. I had to close Firefox from the Task Manager by pressing End process. I had used Firefox for 6 hours without ever closing any of the tabs I had opened.
    In all of these cases, more than 40 tabs were open. In all of these cases, the slow down or freeze meant I had to use Task Manager and then press End process on the Processes tab. In all cases except the two I describe in the next paragraph, I never close any tabs after opening them. No problems have ever happened until Firefox started using 2,7 GB of memory. Until that point, everything is normal with no freezes or slowdowns.
    At two times, I tried to reduce memory usage by closing tabs. However, in both cases this would make Firefox freeze. In one of these cases, Firefox would show something bizarre: there would be about 7 tabs, and one of the tabs would be partly shown. Also, Firefox would show the busy cursor. Firefox did not show how many tabs I actually had. The second time, I tried to close the tabs by clicking Close other tabs in the menu that you get when right-click a tab. The tabs would close fine, but I remember that I opened Gmail and then I did this: I clicked on the Promotions tab. Instead of seeing the tab with the Emails, Firefox showed a busy cursor and the title bar said not responding. Firefox froze.
    The reason might be Adblock Plus memory usage. In Adblock Plus home page, developer Wladimir Palant writes in his blog about how Adblock Plus uses a lot of memory: https://adblockplus.org/blog/on-the-adblock-plus-memory-consumption .

    One more bit of information: I have a Geforce 640 GT graphics card. My graphics card drivers are old- version 311.41. The newest version of the drivers is 340.52. Would a new graphics card driver solve the problem?

  • JSP session getting destroyed when second user logs in

    Hi,
    I am facing a session related problem in a small login program in jsp. I am using three jsp pages, login.jsp (user logs in), page1.jsp (creates a session and stores username) and page2.jsp (accesses session).
    Login.jsp:
    No jsp actually. Just a simple html form.
    Page1.jsp:
    String name=request.getParameter("Name");
    session=request.getSession(true);
    session.setAttribute("Name",name);
    Page2.jsp:
    session=request.getSession(false);
    if(session.isNew())
    System.out.println("new session created");
    String name=session.getAttribute("Name").toString();
    As expected, it works like session getting set at page1 and used at page2. It works good if users log in one by one. The problem arises when 2 (or more users with different logins) try to access the page at same time. When a new user logs in, the previous user session gets destroyed (session.isNew() becomes true and session Id changes).
    Is it the way I am using sessions (missing something), or there is some setting in tomcat server to specify maximum number of logins (sessions that can be handled).
    Regards
    Kamal

    Hi,
    Thanks for reply, but I guess the problem is not clear. Let me explain..
    A user logs in, he reaches first page (page1.jsp), here session is getting set. Then user goes to page2.jsp where application retrieves the information from session and uses it. It works all well.
    When two (or more) user logs in.. First user logs in, he reaches page 1, session is set. But then another user logs in (different id) and a session is set for him as well. Now the problem here is that session for first user gets destroyed at this point, which is unexpected (two sessions should not conflict, on different machines).
    Additionally, the problem does not happen necessarily at second login. eg. sometimes 4 users log in and when fifth one logs in, fourth gets logged out (session gets destroyed).
    I am not able to figure out, whether the problem is in code (given in first post) or there is some tomcat setting responsible for this behavior.
    Regards
    Kamal

  • New Session getting created(!)

              Hi All,
              I am facing a wierd behavior. I have an application with a
              login page(jsp). User submits his authentication details,
              is authenticated in a servlet, and some of his information is
              put in the session. Later he gets "redirected" to another
              jsp(just like any other app).
              This is working fine most of the times. But randomly it is
              so happening that the jsp being redirected to does not get the
              values put in the session.
              Some more debugging showed that from login jsp to servlet, same
              session continued till the very last step(just before
              redirection). Just after
              response.sendRedirect(response.encodeRedirectURL(url));
              a new session gets created(!!). Any pointers?
              Please note I am testing all this out in a browser which is
              accepting cookies.
              

    Urgent!!
              We have the same problem on WLS5.1.
              Any suggestions would be fine
              Regards
              Osman
              "Bijay Kumar" <[email protected]> schrieb im Newsbeitrag
              news:3d0ed20f$[email protected]..
              >
              > Hi All,
              > I am facing a wierd behavior. I have an application with a
              > login page(jsp). User submits his authentication details,
              > is authenticated in a servlet, and some of his information is
              > put in the session. Later he gets "redirected" to another
              > jsp(just like any other app).
              >
              > This is working fine most of the times. But randomly it is
              > so happening that the jsp being redirected to does not get the
              > values put in the session.
              >
              > Some more debugging showed that from login jsp to servlet, same
              > session continued till the very last step(just before
              > redirection). Just after
              > response.sendRedirect(response.encodeRedirectURL(url));
              > a new session gets created(!!). Any pointers?
              >
              > Please note I am testing all this out in a browser which is
              > accepting cookies.
              >
              

  • Bean in Session getting inaccessible after x minutes

    Hi,
    we are currently devloping iViews (JspDynPapes) for EP6 SP2.
    We have several iViews which put bean in the iPortalComponentSession and the HttpSession.
    We have the following problem:
    An iView stores information in a bean and put it into session to be displayed in a table on a JSP. Now,
    if the user waits for x minutes (more than 15!) and he triggers an server side event of the ivew, the iView tries to get the bean back from session. But, if the user has done nothing for a certain period, the bean can not be accessed in that session. This raises an NullPointerException. The bean seems to be disappeared or invalid.
    Do beans stored in a session get invalid or deleted after a certin period? Can this period be customized?
    Thanks for your help,
    Maik

    Hi Maik,
    not the beans stored in the session become invalid but the session itself! For session timeout settings see Anyway to Setting Portal Timeout
    In addition, see http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet/http/HttpSession.html#setMaxInactiveInterval(int) (which overrides the servlet-container settings for this specific session).
    Hope it helps
    Detlev

  • Inactive Sessions Getting Automatically Generated in Database

    I am facing a strange problem of getting huge number of inactive sessions getting generated th the database server which leads to it's connection closure.
    The Error reads as "Failed to check out an Application due to connection failure of Application Module."
    This happens each time I execute the following code:
    String amDefName = "amendprgo.model.CSDInvFRCAmendPrgoServices";
    String configName = "CSDInvFRCAmendPrgoServicesLocal";
    ApplicationModule app1 = Configuration.createRootApplicationModule(amDefName,configName) ;
    String voInstanceName="prgoHdrRO";
    ViewObject prgoHdrROVO =app1.createViewObjectFromQueryStmt(voInstanceName,"select * from INV_PRGO_HDR");
    prgoHdrROVO.setWhereClause("PRGO_ID="+tempRow.getAttribute("PrgoId")+" and DEPOT_CD = '0' and ITEM_CAT = 'I3' ");
    prgoHdrROVO.executeQuery();
    if(prgoHdrROVO.getEstimatedRowCount()>0){
    return true;
    I know there is a process of creating connection and View Object in Model part in JDeveloper, but I want to know why this problem happens.

    ApplicationModule app1 = Configuration.createRootApplicationModule(amDefName,configName) ;is your problem as it causes at least one (sometimes more) connections to open. As you don't free the resource after using it the connection remains open even if you can't access it anymore.
    You should call Configuration.releaseApplicationModule(...), with the application module you created before returning.
    On the other side you shoulnd not even call createRootApplicationModule in the first place (as it causes trouble if you don't deeply know what the framework do with a root application module).
    Can you tell us the use case which make you call createRootApplicationModule()? We might find a better solution.
    Timo
    Edited by: Timo Hahn on 19.05.2011 13:45
    PS: something to read http://blogs.oracle.com/jdevotnharvest/entry/when_to_use_createrootapplicationmodule_in_oracle_adf and http://radio-weblogs.com/0118231/2009/08/20.html#a959

  • Systemd/user: tmux sessions get killed when stopping systemd session

    Following the wiki guide on systemd/user, I am now starting my X sessions using systemd unit files for my user.
    My problem: when I quit X or exit the systemd session (for example through $ systemctl --user exit), my tmux sessions get killed along with it. Note, I do not start tmux with unit files, but simply through invoking “tmux” in a virtual terminal. I have also tried detaching the tmux session before quitting the systemd session, but to no avail.
    How can I make my tmux sessions survive X closing?

    That is beacuse tmux becomes a child process of the systemd --user session.  So it gets caught up in the cgroup and everything.  What I have done is I start a system service of tmux as my user (I have creatively come up with the name "[email protected]").  Here is what I've got, that has been working for me:
    % cat /etc/systemd/system/[email protected]
    [Unit]
    Description=Start detached tmux session
    After=multi-user.target
    Before=shutdown.target
    [Service]
    Type=forking
    User=%I
    WorkingDirectory=%h
    ExecStart=/usr/bin/tmux new-session -d -s %u
    ExecStop=/usr/bin/tmux kill-session -t %u
    Restart=always
    [Install]
    WantedBy=multi-user.target
    Last edited by WonderWoofy (2013-04-27 22:35:27)

  • Session Expired Problem on OAS

    Hi,
    I often got the error message "Session Expired" displayed on my HTML page that serves Java Servlet output after some time.
    I attempted to look through my Servlet source codes but it has no problem. In fact, it runs perfectly well on JavaWebServer2.0.
    This seems to be a OAS problem. I'm using Oracle Application Server 4.0.8.1. I attempted changing the Servlet Cartridge's "Max session idle time" and observe the behaviour. It appears that when "Session Expired" problem happened, my servlet class never get called. OAS simply display a "Session Expired" message on the web page.
    How can I avoid this? How can ask OAS to call my servlet's doGet() to create a new session when it expired?
    Anyone knows how?
    null

    Hi,
    OAS has a limitation of 300 seconds. This value cannot be changed. See the release notes.
    One possible way to get around this is to use the Oracle Supplied Session class and use the time feature in that.
    This a big limitation and I am not sure why Oracle designed the product this way.
    null

  • Session gets hanged when breakpoint is set, else works properly.

    Hello Experts,
      I am expierencing that when i activate the breakpoints in my source code, my sessions gets hanged up.But when i remove the same breakpoint , i get to see the output. I have all the rights , and i use to debug till this last week.
    Can anyone help me in this issue.
    Thanks in advance.
    Swapnil

    Hi, Waghmare
    Please Check your GUI version and Patch Level i think problem is with your GUI
    Follow Steps Bellow
    --> Press ALT + F12
    --> From the menu Select About from here you can Check the Version and Patch Level
    Regards,
    Faisal
    Edited by: Faisal Altaf on Feb 1, 2010 3:12 PM

  • Frequently getting Problem loading page -saying becuase cookies may be disabled

    Acer Aspire 7551-7422 Windows 7 Home Premium, FireFox 6.0
    I frequently get problem loading page messages which state that it is sometimes caused by disabling or refusing cookies. I have all cookies allowed in FireFox options, I frequently clear cookies also. What else might the problem be? FireFox is allowed through my fire wall.

    You only need to allow cookies if you let them expire if Firefox closes and you want to keep some for the next session.<br />
    If you keep cookies until they expire then you shouldn't need to set an allow exception.
    Try to clear the cookies from sites that cause problems.
    *Tools > Options > Privacy > Firefox will: "Use custom settings for history" > Cookies: "Show Cookies"
    If clearing the cookies doesn't help then it is possible that the file <i>cookies.sqlite</i> that stores the cookies is corrupted.<br />
    Rename (or delete) <b>cookies.sqlite</b> (cookies.sqlite.old) and delete <b>cookies.sqlite-journal</b> and <b>cookies.txt</b>, if they exist, in the Firefox Profile Folder in case the file cookies.sqlite got corrupted.
    * http://kb.mozillazine.org/Profile_folder_-_Firefox

  • I get problem loading page (error 404) it says the page cannot be found when i try to access the game Mobsters through my mysapce account and i cannot access it no longer through firefox and i want to find out why i cant, can you guys please help?

    i cant access my mobsters account through myspace. every time i try to access it i get "problem loading page" "this page cannot be found" "404 error" and it wont let me access it. myspace works fine but as soon as i click on the mobsters app i get the 404 error, this page cannot be found, problem loading page! can you please help?
    == This happened ==
    Every time Firefox opened
    == i try to access mobsters game through myspace

    I dont understand the answer
    '''''""The problem can be solved by opening FF and choosing Tools...Add On's...select the SEARCH addon and choose UNINSTALL...restart FF browser when asked, then reload Mobsters. This worked for me. The suggestion on the 404 that says to remove Search via Add/Remove Programs is completely BS, as Search doesnt show there. ""'''''

  • Getting problem while posting Invoice

    Hi all,
            Ofcourse this problem is related functional thing, i am posting in ABAP group. we are getting problem while posting invoice through f-43 transaction. The error is "Fiscal year 0000 not allowed for year-dependent commitment items". Please let me know if u have any solution.
    Thanks in advance.
    chandrasekhar.

    Hi chandrasekhar,
    pls post some infos:
    1) application aerea of the message and message no.
    2) document date / posting date
       and ohter date-fileds of the document
    3) SAP-Release
    Have you search in SAP-OSS with the message no. or
    message text ?
    regards Andreas

  • Urgent, Please help me in this problem.I am getting problem while installation

    I am using Windows 8 in my system. I am trying to install Sql Server in system . Everything is fine, but finally  when i click on install button i am getting the following error .
    please help me quickly. I well be thankful to you.

    Triple post meanwhile:
    http://social.msdn.microsoft.com/Forums/en-US/7fafa499-ca1e-42f7-a117-73df924d9847/urgent-please-help-me-in-this-problemi-am-getting-problem-while-installation?forum=sqlsetupandupgrade
    http://social.msdn.microsoft.com/Forums/en-US/a1c7978c-2f84-495f-a8b6-9e9fe46654d7/getting-problem-while-installing-sql-server-2012?forum=sqlsetupandupgrade
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

Maybe you are looking for