Commit session

Hi
I have some requirement such that i have to fill a table thru DBlink and number of records are too high...
Is there any way i can Commit the session after regular intervals say after every 1 million recrds or so.
Thanks in advance.

> Is there any way i can Commit the session after regular intervals say after every 1 million
recrds or so
I can not understand where people get the idea that commits make things go faster. A COMMIT does work. It is not NOOP (No Operation) statement. It does processing.. it does some kind of work and stuff in the database.
Can you perhaps explain to me how you are intending to make things faster by doing more work (using COMMITs) for that process?
I'm sure I must be missing something as it seems every second poster here is of the opinion that if they can do more COMMITs, more work, their processes will be faster.
Are you guys running Oracle Socialist Database 10G with Communist Extensions or something? You know.. some weird database extension and enhancement whose sensibility (more work is faster comrades!) those of us in the real world cannot ever hope to grasp?

Similar Messages

  • Externally commit session

    Hi all,
    I have a problem with one software (no Oracle software), and sometimes happens that after a long time query it go to idle state, but that query ends OK. The only commit waiting for execute. But that software when does not responds.
    Is there any way to commit some session from another session, or to connect to session and then do the commit.
    Thanks a lot for your help.
    Ales
    Sorry for my poor English I hope that someone will understand my question.

    Ok I hoped that there is any way, but anyway Thank you for your answer.
    This is the first time that on any forum somebody answer so early.
    Thanks Ales

  • JTA Transaction and CUrrent Session

    We have the following problem. We configured hibernate with
    jta and when we execute a simple code that performs some hibernate
    queries we get the following error:
    "org.hibernate.LazyInitializationException: could not
    initialize proxy - the owning Session was closed"
    We discovered that if we leave the session opened the error
    disapears, but on the long run this crashes the server throwing a
    JDBC connection error.
    We tried to use getCurrentSession() instead of opening the
    session manualy but in this case we get the following error:
    "org.hibernate.HibernateException : Unable to locate current
    UserTransaction"
    This its quite strange because the current session should be
    bound to the current user transaction and its seems to us that our
    hibernate cfg file its ok.
    I´am posting part of my hibernate cfg file and the code
    that I execute.
    hibernate.cfg.xml
    <hibernate-configuration>
    <session-factory name="java:/hibernate/SessionFactory">
    <property
    name="hibernate.connection.datasource">java:fiap</property>
    <property
    name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
    <!-- Enable Hibernate's automatic session context
    management -->
    <property
    name="hibernate.current_session_context_class">jta</property>
    <property
    name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactor y</property>
    <property
    name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransact ionManagerLookup</property>
    <property
    name="jta.UserTransaction">java:comp/UserTransaction</property>
    <!-- <property
    name="connection.release_mode">after_statement</property>
    -->
    <!-- <property
    name="hibernate.transaction.flush_before_completion">true</property>-->
    <property
    name="hibernate.transaction.auto_close_session">true</property>
    and my java Code:
    try {
    tx = HUtil.getTx(); //JNDI lookup
    tx.begin();
    session = HUtil.getSessionFactory().getCurrentSession();
    //JNDI Lookup
    //session = HUtil.getSessionFactory().openSession();
    Query query = session.createQuery("from Persona where
    username = ?");
    query.setString(0, userName);
    persona = (Persona) query.uniqueResult();
    query = session.createQuery("from Festival where id = ?");
    query.setInteger(0, idFestival);
    festival = (Festival) query.uniqueResult();
    if (persona != null && festival != null) {
    query = session.createQuery("from Inscripcion where
    inscribeA = :persona " +
    "AND inscriptosEn = :festival");
    query.setParameter("persona", persona);
    query.setParameter("festival", festival);
    inscripcion = (Inscripcion) query.uniqueResult();
    return inscripcion;
    } catch (Exception e) {
    e.printStackTrace();
    throw e;
    } finally {
    tx.commit();
    //session.close();
    thanks

    The scenario you described is typical ... "If a client calls m1" ... there are 2 cases:
    (1) the client is already in a trans
    (2) not (1)
    Let (1). This is the case of a Client Controlled Transaction ... etc ... when s1 is called it begins a transaction in the client transactional context ... hence s1 can't call a kind of roolback but can force the rollback of the global transaction marking EJBContext.setRollbackOnly() ... s2 uses the same transactional context ... anayway the client is the only one that can commit. This happens because of "transaction required" as the transaction attribute, that in this case forces a flat transaction model. Different is the case if you uses "requiredNew" --> nested trans model ...
    (2) is the same of (1) except that the trans starts at application tier.
    "I still have one doubt. Wouldn't the stateless session bean loose the transaction context once I exit the second stateles session bean's method? Isn't that what stateless means? "
    No:
    stateless doesn't stay for the transaction context but for the conversational state with the client ... that is serializable ... it makes the beans more poolable ... that the stateful session bean has
    bye

  • Commit of Unit of Work

    public static ToplinkTrattative1 doProvaUpdate(Double idTrattativa) {
    ConversionManager.getDefaultManager().setShouldUseClassLoaderFromCurrentThread(true);
    oracle.toplink.sessions.Project project = XMLProjectReader.read("/C:/Documents and Settings/Cheru.CHERUBBOLO/Desktop/tirocinio/jdev9052new/jdev/mywork/tirocinio/Model/src/META-INF/Model/toplink-deployment-descriptor.xml");
    DatabaseSession session = project.createDatabaseSession();
    session.login();
    Expression exp = new ExpressionBuilder().get("idTrattativa").equal(idTrattativa);
    ToplinkTrattative1 tc = (ToplinkTrattative1)session.readObject(model.ToplinkTrattative1.class, exp);
    session.beginTransaction();
    UnitOfWork uow=session.acquireUnitOfWork();
    tc.setNote("prova");
    tc.setStato(new Character('A'));
    ToplinkTrattative1 v=(ToplinkTrattative1)uow.registerObject(tc);
    uow.mergeClone(tc);
    uow.commit();
    session.commitTransaction();
    return v;
    and in session the transaction is commited but not in DB.
    I use toplink for model and Stuts/JSP for View.
    Thx for all

    A few issues with this,
    First,
    session.beginTransaction();
    UnitOfWork uow=session.acquireUnitOfWork();...
    uow.commit();
    session.commitTransaction();When using the UnitOfWork the DatabaseSession beginTransaction/commitTransaction API should not be used. The UnitOfWork manages the transaction. DatabaseSession beginTransaction/commitTransaction are only provided for use with the basic writeObject API.
    Second,
    ToplinkTrattative1 tc = (ToplinkTrattative1)session.readObject(model.ToplinkTrattative1.class, exp);
    UnitOfWork uow=session.acquireUnitOfWork();
    tc.setNote("prova");
    tc.setStato(new Character('A'));
    ToplinkTrattative1 v=(ToplinkTrattative1)uow.registerObject(tc);
    uow.mergeClone(tc);You cannot modify objects read from the Session, you can only modify the returned clones of objects that have been register in a UnitOfWork. You must first register the object, and then make your changes. By changing the object before registering it the UnitOfWork will not detect any changes, and will not commit anything to the database.
    It should be,
    UnitOfWork uow=session.acquireUnitOfWork();
    ToplinkTrattative1 v =(ToplinkTrattative1)uow.registerObject(tc);
    v.setNote("prova");
    v.setStato(new Character('A'));
    uow.commit();

  • Toplink Sessions and Caching

    Hi
    I've got a external import on my DB, which updates the database without toplink. => cache is after update not uptodate.
    So I've tried to run after every update of the DB:
    getClientSession().getIdentityMapAccessor().initializeAllIdentityMaps();
    (running on a oracle.toplink.sessions.Session - Object)
    How can i refresh the cache for all Sessions, not only the actual ClientSession? Or is ther just one session (the actual ClientSession) for Toplink? The application is a webbased application with more then one user....
    getClientSession is implemented as follow:
    public Session getClientSession() {
    try {
         mySessionBroker = (SessionBroker) SessionManager.getManager().getSession(TOPLINK_SESSION_NAME, AbstractService.class.getClassLoader());
         Session clientSession = (Session) mySessionBroker.acquireClientSessionBroker();
    clientSession.setSessionLog( new Log4jSessionLog() );
         clientSession.setLogLevel(ClientSession.LOG_DEBUG);
    //clientSession.logMessages();
         return clientSession;
    catch (Exception e) {
    throw new RuntimeException(new ClicToplinkException(e));
    }

    I realize this is an old thread so I apologize for dragging it back up.
    I am trying to get a handle on the cache invalidation methods. We need to invalidate the cache based on sporadic manual updates and I would like to figure out the best methodology for doing this. I believe that the IdentityMapAccessor.invalidateAll() method is the one I need to use but can't get it to work. What follows is my test case. this.manager is an entity manager created in a setup method:
    this.manager.getTransaction().begin();
    this.user = new FormularyUser();
    this.user.setSecurityUserID(12345L);
    this.manager.persist(this.user);
    this.manager.getTransaction().commit();
    Session session = ((EntityManagerImpl)this.manager.getDelegate()).getServerSession();
    session.getIdentityMapAccessor().invalidateAll();
    // this should lookup from DB
    FormularyUser copy2 = this.manager.find(FormularyUser.class,this.user.getUserPK());
    assertTrue(copy2 != null);
    assertTrue(copy2 != this.user);
    It would be my assumption that the invalidated cache result would not be returned but as I traced through the code I noticed this comment:
    'Override the getFromIdentityMapWithDeferredLock method on the session to ensure that invalidated objects are always returned since this is a UnitOfWork'
    Does this mean because I'm still in the same unit of work that I will get invalid objects back? I would assume that because I had committed the transaction that I would be in a new UnitOfWork. Can someone point out where I'm making the wrong assumptions or what I'm doing wrong?
    Thanks,
    Drew

  • Help me with my session.update() please....

    Hi there again...
    I want to ask something very annoying for me.
    Here i have some code to update my data. It would be like this:
         public void updateTopicReply(Integer id,Integer reply) {
              Topic topic = null;
              Session session = null;
              Transaction tx = null;
              session = HibernateSessionFactory.currentSession();
              reply=reply+1;
              topic = (Topic) session.get(Topic.class, id);
              topic.setReply(reply);
              tx = session.beginTransaction();
              session.update(topic);
              tx.commit();
         session.close();
    when i saw it again in my jsp, no its not changed. But when I press F5, yeaaaa, it's been updated.
    But when i press F5 again, it changed back again. And I keep press F5, it's just like the lamp of christmas tree...
    So i read some more and I try to add this flush() and refresh()
              tx = session.beginTransaction();
              session.update(topic);
              session.flush();
              session.refresh(topic);
              tx.commit();
    But, man.It's still the same.
    Anyone know what is the problem?
    Any idea or solution u can share?
    Or any other method to give?

    It all depends on the number of beeps.  Please count the beeps and post the amount. Put in the original ram.
    Reslot your ram if you truly believe it is that.

  • Effect of Multiversion Concurrency Control on Isolation

    Suppose I have a table defined as follows:
    create table duty
    (person char(30),
    status char(3)
    And it has the following contents:
    select * from duty;
    PERSON STATUS
    Greg on
    Heping on
    If I do the following in two sessions as outlined:
    *** Session 1 ***
    set transaction isolation level serializable;
    *** Session 2 ***
    set transaction isolation level serializable;
    *** Session 1 ***
    select * from duty where person = 'Greg';
    PERSON STATUS
    Greg on
    -- Since Greg is 'on' we'll set Heping 'off'.
    *** Session 2 ***
    select * from duty where person = 'Heping';
    PERSON STATUS
    Heping on
    -- Since Heping is 'on' we'll set Greg 'off'.
    *** Session 1 ***
    update duty set status = 'off' where person = 'Heping';
    *** Session 2 ***
    update duty set status = 'off' where person = 'Greg';
    *** Session 1 ***
    commit;
    *** Session 2 ***
    commit;
    Then, my table contains
    select * from duty;
    PERSON STATUS
    Greg off
    Heping off
    If these two transactions had been executed according to the SQL92 standard for transaction isolation level serializable, that is in one order or the other, then the status of these two rows would not both be 'off' (because I would not have executed the update if I saw the status off).
    I note that Sybase seems to correctly handle these transactions in serializable mode if I execute them just as show above in that it identifies a deadlock between the two and forces one to rollback.
    Does Oracle not implement the SQL92 Standard with respect to transaction isolation levels? Is this behavior due to Multi-Version Concurrency Control?
    Thanks,
    G.Carter

    The couple of responses are very much appreciated. I especially found the link to Tom Kyte's article, "On Transaction Isolation Levels" (http://www.oracle.com/technology/oramag/oracle/05-nov/o65asktom.html) enlightening.
    My conclusion is that different SQL database vendors may claim compliance with the SQL-92 standard despite the fact that their databases exhibit different behaviors and yield different answers under like circumstances because the SQL-92 standard is self inconsistent. In particular, on the one hand, the standard states that:
    [1]A serializable execution is defined to be an execution of the operations of
    concurrently executing SQL-transactions that produces the same effect as
    some serial execution of those same SQL-transactions.
    And on the other hand (in fact, in the very next paragraph), the standard states that:
    [2]The isolation level specifies the kind of phenomena ["Dirty read", "Non-repeatable read", "Phantom"]
    that can occur during the execution of concurrent SQL-transactions.
    Whereas Sybase can emphasize [1] as a justification for its behavior, Oracle can emphasize [2] to justify its behavior, and under like circumstances, those behaviors yield different results.
    Unfortunately, I (and I've got to believe that many others as well) do not have the luxury of building an application that will work with only one vendor's database.
    Thanks,
    G.Carter

  • Problem with store procedures and Hibernate

    I got some problem when I am trying to override INSERT, and UPDATE operations in Hibernate. My delete functions works fine, and everything works when i´m not override with my stored procedure, and I have no idea why. When I am trying to make an INSERT, everything seems to be fine but no data is being insert and no excpetion throws.
    When I am trying to make an UPDATE following excpetion throws:
    Could not synchronize database state with session
    org.hibernate.exception.GenericJDBCException: could not update: [labb6Hibernate.bil#18]
    Here is my hbm.xml file:
    <hibernate-mapping>
    <class catalog="Cars" name="labb6Hibernate.bil" table="Bil">
    <id name="idNum" type="java.lang.Integer">
    <column name="idNum"/>
    <generator class="identity"/>
    </id>
    <property name="marke" type="string">
    <column length="10" name="Marke" not-null="true"/>
    </property>
    <property name="modell" type="string">
    <column length="10" name="Modell" not-null="true"/>
    </property>
    <property name="arsmodell" type="string">
    <column length="4" name="Arsmodell" not-null="true"/>
    </property>
    <sql-insert callable="true"> { call insertCars(?,?,?) } </sql-insert>
    <sql-update callable="true"> { call updateCars(?,?,?) </sql-update>
    <sql-delete callable="true"> { call deleteCars(?) } </sql-delete>
    </class>
    Here is my UPDATE code:
    Session session = MyHibernateUtil.getSessionFactory().openSession();
    session.beginTransaction();
    int s = Integer.parseInt(idTxt.getText());
    bil Bil = (bil) session.get(bil.class, s);
    Bil.setIdNum(s);
    Bil.setMarke(markeTxt.getText());
    Bil.setModell(modellTxt.getText());
    Bil.setArsmodell(arsmodellTxt.getText());
    session.update(Bil);
    session.getTransaction().commit();
    session.close();
    Here is my INSERT code:
    Session session = MyHibernateUtil.getSessionFactory().openSession();
    session.beginTransaction();
    bil Bil = new bil();
    Bil.setMarke(markeTxt.getText());
    Bil.setModell(modellTxt.getText());
    Bil.setArsmodell(arsmodellTxt.getText());
    session.save(Bil);
    session.getTransaction().commit();
    session.close();
    Does anyone have an idea what is wrong in my code?

    I got some problem when I am trying to override INSERT, and UPDATE operations in Hibernate. My delete functions works fine, and everything works when i´m not override with my stored procedure, and I have no idea why. When I am trying to make an INSERT, everything seems to be fine but no data is being insert and no excpetion throws.
    When I am trying to make an UPDATE following excpetion throws:
    Could not synchronize database state with session
    org.hibernate.exception.GenericJDBCException: could not update: [labb6Hibernate.bil#18]
    Here is my hbm.xml file:
    <hibernate-mapping>
    <class catalog="Cars" name="labb6Hibernate.bil" table="Bil">
    <id name="idNum" type="java.lang.Integer">
    <column name="idNum"/>
    <generator class="identity"/>
    </id>
    <property name="marke" type="string">
    <column length="10" name="Marke" not-null="true"/>
    </property>
    <property name="modell" type="string">
    <column length="10" name="Modell" not-null="true"/>
    </property>
    <property name="arsmodell" type="string">
    <column length="4" name="Arsmodell" not-null="true"/>
    </property>
    <sql-insert callable="true"> { call insertCars(?,?,?) } </sql-insert>
    <sql-update callable="true"> { call updateCars(?,?,?) </sql-update>
    <sql-delete callable="true"> { call deleteCars(?) } </sql-delete>
    </class>
    Here is my UPDATE code:
    Session session = MyHibernateUtil.getSessionFactory().openSession();
    session.beginTransaction();
    int s = Integer.parseInt(idTxt.getText());
    bil Bil = (bil) session.get(bil.class, s);
    Bil.setIdNum(s);
    Bil.setMarke(markeTxt.getText());
    Bil.setModell(modellTxt.getText());
    Bil.setArsmodell(arsmodellTxt.getText());
    session.update(Bil);
    session.getTransaction().commit();
    session.close();
    Here is my INSERT code:
    Session session = MyHibernateUtil.getSessionFactory().openSession();
    session.beginTransaction();
    bil Bil = new bil();
    Bil.setMarke(markeTxt.getText());
    Bil.setModell(modellTxt.getText());
    Bil.setArsmodell(arsmodellTxt.getText());
    session.save(Bil);
    session.getTransaction().commit();
    session.close();
    Does anyone have an idea what is wrong in my code?

  • IStudio hanging while trying to open a project

    Hi,
    iStudio throws application( DB adapetr) error at the startup, when OK is
    clicked on the messages, it hangs showing the status as "Loading deploy view".
    Actually iStudio got closed during creating an event in B2BApp (DB
    adapter).When opened for the next time it gave above error.
    nothing worked with stopping & starting the adapeters & repository.
    Messageinfoidtable has following error entry in description column:
    "AQ Adapter: ** Error ** unable to restart database and AQ connections."
    & "XMLAQAdapter_restartFailed" entry in internalID.
    Starting of AQ Adapater is throwing following error:
    AQ Adapter: restarting database and AQ connections.
    AQ Adapter: resubscribing to queue IP_IN_QUEUE.
    AQ Adapter: ** Error ** unable to restart database and AQ connections.
    java.sql.SQLException: ORA-01017: invalid username/password; logon denied
    at
    oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java
    :124)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:304)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:271)
    at
    oracle.jdbc.driver.T4CTTIoauthenticate.receiveOsesskey(T4CTTIoauthent
    icate.java:242)
    at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:297)
    at
    oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:
    346)
    at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:149)
    at
    oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtensio
    n.java:31)
    at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:543)
    at java.sql.DriverManager.getConnection(DriverManager.java:512)
    at java.sql.DriverManager.getConnection(DriverManager.java:171)
    at
    oracle.oai.common.database.DBConnection.connectToDatabase(DBConnectio
    n.java:482)
    at
    oracle.oai.common.database.DBConnection.connectOnce(DBConnection.java
    :314)
    at
    oracle.oai.agent.common.oracleaq.AQSessionFactory.getAQSession(AQSess
    ionFactory.java:47)
    at
    oracle.oai.agent.common.oracleaq.AQManager.createAQSession(AQManager.
    java:482)
    at
    oracle.oai.agent.common.oracleaq.AQManager.subscribeQueue(AQManager.j
    ava:421)
    at
    oracle.oai.agent.common.oracleaq.AQManager.resubscribe(AQManager.java
    :407)
    at
    oracle.oai.agent.common.oracleaq.AQManager.restart(AQManager.java:210
    at oracle.oai.agent.common.Restarter.doOperation(Restarter.java:42)
    at oracle.oai.agent.common.TimerThread.run(TimerThread.java:74)
    Adapetr entries are as follows:
    // Bridge class
    bridge_class=oracle.oai.agent.adapter.aq.XMLAQBridge
    // AQ database connection info
    aq_bridge_username=xxxx // aq_bridge_username=b2buser
    //the value of the property "aq_bridge_password" is taken from the
    Wallet.
    aq_bridge_host=oradisc
    aq_bridge_port=1521
    aq_bridge_instance=aaa
    aq_bridge_owner=aaa
    aq_bridge_consumer_name=B2BUSER
    aq_bridge_use_thin_jdbc=true
    Is there any link between the starting up of iStudio n AQ adaapter?
    If password needs to be changed then where can I do the changes, as password is stored in wallet, how to search the wallet utlility?

    Hi Colette,
    Thnx for the reply.
    Yes u r right, the whole intergration consists of AQ, DB & FTP adapter applications, connecting with B2B.
    Infact B2BUser entry is commented here.
    The inital error coming is error loading in DB application( in which I was creating some event)....then iStudio hangs showing loading deploy view.
    I tried with changing the entries suggested, still facing same issue.
    Is my metadata corrupted due to some wrong/incomplete event creation?
    Can I delete the entries from the messageinfoidtable for the event I was trying to create?
    How to check the password entries from wallet..I mean what all steps involved to check the same.
    Below is the ini file entiries for the AQ adapter:
    // Bridge class
    bridge_class=oracle.oai.agent.adapter.aq.XMLAQBridge
    // AQ database connection info
    aq_bridge_username=ichub // aq_bridge_username=b2buser
    //the value of the property "aq_bridge_password" is taken from the Wallet.
    aq_bridge_host=oradisc
    aq_bridge_port=1521
    aq_bridge_instance=b2b
    aq_bridge_owner=b2b
    aq_bridge_consumer_name=B2BUSER
    aq_bridge_use_thin_jdbc=true
    +++++++++++++++++++++++++++
    +++++++++++++++++++++++++++
    Below is the iStudiolog.txt entries: any pointers from below file?
    10:47 AM 9/29/200510:47 AM 9/29/2005LOW: 20
    HIGH: 40
    MAX: 120
    DEBUG: true
    ADT Support: true
    Connecting to repository
    RepoConnection: Got IOR!
    Bound to EventMgr
    Bound to EMDMgr
    Bound to AgentATMgr
    Bound to LCOMgr
    Bound to DSOMgr
    Bound to RepoMgr
    SessionName:iStudio@sgistudio
    COMMIT SESSION CALLED.
    ENDSESSION CALLED.
    CACHE compaction algorithm running...
    CACHE SIZE: 0
    CACHE SIZE: 0
    CACHE SIZE: 0
    CACHE SIZE: 0
    CACHE SIZE: 0
    CACHE SIZE: 0
    CACHE SIZE: 0
    CACHE SIZE: 0
    CACHE SIZE: 0
    CACHE SIZE: 0
    CACHE SIZE: 0
    CACHE SIZE: 0
    CACHE SIZE: 0
    CACHE SIZE: 0
    END CACHE compaction algorithm.
    END SESSION CALLED BY COMMIT SESSION.
    CACHE SIZE: 1
    CACHE SIZE: 2
    CACHE SIZE: 3
    CACHE SIZE: 4
    CACHE SIZE: 5
    CACHE SIZE: 6
    CACHE SIZE: 7
    CACHE SIZE: 8
    CACHE SIZE: 9
    CACHE SIZE: 10
    CACHE SIZE: 11
    CACHE SIZE: 12
    CACHE SIZE: 13
    CACHE SIZE: 14
    CACHE SIZE: 15
    CACHE SIZE: 16
    CACHE SIZE: 17
    CACHE SIZE: 1
    CACHE SIZE: 2
    CACHE SIZE: 3
    CACHE SIZE: 1
    Event Map does not exist
    CACHE SIZE: 1
    CACHE SIZE: 2
    Event Map does not exist
    CACHE SIZE: 2
    CACHE SIZE: 3
    Event Map does not exist
    CACHE SIZE: 3
    CACHE SIZE: 4
    Event Map does not exist
    CACHE SIZE: 4
    CACHE SIZE: 5
    Event Map does not exist
    CACHE SIZE: 5
    CACHE SIZE: 6
    Event Map does not exist
    CACHE SIZE: 6
    CACHE SIZE: 7
    Event Map does not exist
    CACHE SIZE: 7
    CACHE SIZE: 8
    Event Map does not exist
    CACHE SIZE: 8
    CACHE SIZE: 9
    Event Map does not exist
    CACHE SIZE: 9
    CACHE SIZE: 10
    Event Map does not exist
    CACHE SIZE: 10
    CACHE SIZE: 11
    Event Map does not exist
    CACHE SIZE: 11
    +++++++++++++++++++++++++++++++++++++++++++++
    Any pointers how to check the password entries in the wallet?

  • How can apply query in Hibenrate?

    Hi !
    I am using Hibenrate.and i need to know how to provide CRUD operation in Hibenrate.
    I write the code for Inserting data in table.but when i want to read data there is a probs...
    i have one table named book in My Sql server 5.0. in which id and bookname two fields are there...
    now i have created 4 files...
    1. Book.java (Entity beans)
    2. book.hbm.xml (configuration beans with table in db)
    3. IdIncrementExample.java (java file from which i am applying CRUD operation)
    4. hibernate.cfg.xml (hibernate configuration)
    Now the code is as follow.....
    1. Book.java
    public class Book {
    private long lngBookId;
    private String strBookName;
    * @return Returns the lngBookId.
    public long getLngBookId() {
    return lngBookId;
    * @param lngBookId The lngBookId to set.
    public void setLngBookId(long lngBookId) {
    this.lngBookId = lngBookId;
    * @return Returns the strBookName.
    public String getStrBookName() {
    return strBookName;
    * @param strBookName The strBookName to set.
    public void setStrBookName(String strBookName) {
    this.strBookName = strBookName;
    2. book.hbm.xml
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <hibernate-mapping>
         <class name="Book" table="book">
              <id name="lngBookId" type="long" column="id" >
    <generator class="increment"/>
              </id>
              <property name="strBookName">
    <column name="bookname" />
              </property>
         </class>
    </hibernate-mapping>
    3. hibernate.cfg.xml
    <?xml version='1.0' encoding='utf-8'?>
    <!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
    <hibernate-configuration>
    <session-factory>
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/test</property>
    <property name="hibernate.connection.username">root</property>
    <property name="hibernate.connection.password">root</property>
    <property name="hibernate.connection.pool_size">10</property>
    <property name="show_sql">true</property>
    <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
    <property name="hibernate.hbm2ddl.auto">update</property>
    <!-- Mapping files -->
    <mapping resource="book.hbm.xml"/>
    </session-factory>
    </hibernate-configuration>
    4. IdIncrementExample.java
    import org.hibernate.Session;
    import org.hibernate.SessionFactory;
    import org.hibernate.cfg.Configuration;
    import java.io.*;
    import org.hibernate.*;
    import java.util.*;
    * @author Administrator
    public class IdIncrementExample {
    public static void main(String[] args) {
    Session session = null;
         DataInputStream din =new DataInputStream(System.in);
         String B_Name=new String();
         int B_No;
    try{
    // This step will read hibernate.cfg.xml and prepare hibernate for use
    SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
    session =sessionFactory.openSession();
    Transaction txsave = session.beginTransaction();
    //Create new instance of Contact and set values in it by reading them from form object
    System.out.println("Inserting Book object into database..");
    Book book = new Book();
    book.setStrBookName("Tutorial");
    session.saveOrUpdate(book);
    System.out.println("Book object persisted to the database.\n\n");
    txsave.commit();
    System.out.println(" Save Completed");
         Transaction txupdate = session.beginTransaction();
         System.out.print("Please Enter The Book No :: ");
              B_No = Integer.parseInt(din.readLine());
         String SQL_QUERY ="update Book set bookname= 'Hackers' where id= :va";
         // System.out.println("\n String is :: " + SQL_QUERY);
         int p= session.createQuery(SQL_QUERY)
    .setString("va","6")
    .executeUpdate();
         for(Iterator it=query.iterate();it.hasNext();)
              System.out.println("First");
              Book b1=(Book)it.next();
              System.out.println("ID: " + b1.getStrBookName());
              System.out.println("Name: " + b1.getStrBookName());
                   book.setLngBookId(B_No);
              System.out.print("Please Enter The Book Name :: ");
              B_Name = din.readLine();
                   book.setStrBookName(B_Name);
              session.saveOrUpdate(book);
              System.out.println("Book object persisted to the database.");
    txupdate.commit();
    session.close();
    }catch(Exception e){
    System.out.println(e.getMessage());
    }finally{
    and when i run this code at that time the following errors ill genrate.....
    init:
    deps-jar:
    Compiling 1 source file to C:\Documents and Settings\Administrator\My Documents\Hibernate\build\classes
    Note: C:\Documents and Settings\Administrator\My Documents\Hibernate\src\IdIncrementExample.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    compile:
    run:
    log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
    log4j:WARN Please initialize the log4j system properly.
    Inserting Book object into database..
    Hibernate: select max(id) from book
    Book object persisted to the database.
    Hibernate: insert into book (bookname, id) values (?, ?)
    Save Completed
    5
    Exception in thread "main" java.lang.NoClassDefFoundError: antlr/ANTLRException
    at org.hibernate.hql.ast.ASTQueryTranslatorFactory.createQueryTranslator(ASTQueryTranslatorFactory.java:35)
    at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:74)
    at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:56)
    at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:72)
    at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
    at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
    at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1623)
    at IdIncrementExample.main(IdIncrementExample.java:58)
    Please Enter The Book No ::
    Java Result: 1
    BUILD SUCCESSFUL (total time: 54 seconds)
    I am using Netbeans 5.5
    and the sql file which is....here...
    SQLyog - Free MySQL GUI v5.15
    Host - 5.0.24-community-nt : Database - test
    Server version : 5.0.24-community-nt
    SET NAMES utf8;
    SET SQL_MODE='';
    create database if not exists `test`;
    USE `test`;
    SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO';
    /*Table structure for table `book` */
    DROP TABLE IF EXISTS `book`;
    CREATE TABLE `book` (
    `id` int(5) NOT NULL,
    `bookname` varchar(20) default NULL,
    PRIMARY KEY (`id`)
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
    /*Data for the table `book` */
    insert into `book` (`id`,`bookname`) values (1,'abc');
    insert into `book` (`id`,`bookname`) values (2,'Hibernate Tutorial');
    insert into `book` (`id`,`bookname`) values (3,'sds');
    insert into `book` (`id`,`bookname`) values (4,'Hibernate Tutorial');
    insert into `book` (`id`,`bookname`) values (5,'Tutorial');
    insert into `book` (`id`,`bookname`) values (6,'Tutorial');
    insert into `book` (`id`,`bookname`) values (7,'Tutorial');
    insert into `book` (`id`,`bookname`) values (8,'Tutorial');
    insert into `book` (`id`,`bookname`) values (9,'Tutorial');
    insert into `book` (`id`,`bookname`) values (10,'Tutorial');
    insert into `book` (`id`,`bookname`) values (11,'Tutorial');
    insert into `book` (`id`,`bookname`) values (12,'Tutorial');
    insert into `book` (`id`,`bookname`) values (13,'Tutorial');
    insert into `book` (`id`,`bookname`) values (14,'Tutorial');
    insert into `book` (`id`,`bookname`) values (15,'Tutorial');
    insert into `book` (`id`,`bookname`) values (16,'Tutorial');
    SET SQL_MODE=@OLD_SQL_MODE;
    test is the database name......and book is the table name...
    =======================================================
    can any one help me......

    I was kind of kidding as I've written one and therefore have a vested interest.
    However, hibernate.org should be your first port of call.
    The creators of Hibernate have written a tome called "Java Persistence with Hibernate" that I've not read, but which has good reviews so far. They also wrote "Hibernate In Action" which is good, but slightly out of date. I'd also say that that one's only so-so for beginners.
    My book is Beginning Hibernate, which I think is good for (duh) beginners.
    There are others, but I don't feel obliged to try and sell you them as the ones I've read are mediocre.
    D.

  • How do you update multiple items in a JSP that are only checked...

    I have list of items in my jsp pages and that are being generated by the following code
    and I want to be able to update multiple records that have a checkbox checked:
    I have a method to update the status and employee name that uses hibernate that takes the taskID
    as a paratmeter to update associated status and comments, but my issue is how to do it with multiple records:
    private void updateTaskList(Long taskId, String status, String comments) {
    TaskList taskList = (TaskList) HibernateUtil.getSessionFactory()
                   .getCurrentSession().load(TaskList.class, personId);
    taskList.setStatus(status);
    taskList.setComment(comments);
    HibernateUtil.getSessionFactory().getCurrentSession().update(taskList);
    HibernateUtil.getSessionFactory().getCurrentSession().save(taskList);
    <table border="0" cellpadding="2" cellspacing="2" width="98%" class="border">     
         <tr align="left">
              <th></th>
              <th>Employee Name</th>
              <th>Status</th>
              <th>Comment</th>
         </tr>
         <%
              List result = (List) request.getAttribute("result");
         %>
         <%
         for (Iterator itr=searchresult.iterator(); itr.hasNext(); )
              com.dao.hibernate.TaskList taskList = (com.dao.hibernate.TaskList)itr.next();
         %>     
         <tr>
              <td> <input type="checkbox" name="taskID" value=""> </td>
              <td>
                   <%=taskList.empName()%> </td>           
              <td>          
                   <select value="Status">
                   <option value="<%=taskList.getStatus()%>"><%=taskList.getStatus()%></option>
                        <option value="New">New</option>
                        <option value="Fixed">Fixed</option>
                        <option value="Closed">Closed</option>
                   </select>          
    </td>
              <td>               
                   <input type="text" name="Comments" MAXLENGTH="20" size="20"
                   value="<%=taskList.getComments()%>"></td>
         </tr>
    <%}%>
    _________________________________________________________________

    org.hibernate.exception.GenericJDBCException: could not load an entity: [com.dao.hibernate.WorkList#2486]
    org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:91)
    org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:79)
    org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
    org.hibernate.loader.Loader.loadEntity(Loader.java:1799)
    org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:93)
    org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:81)
    org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2730)
    org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:365)
    org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:346)
    org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:123)
    org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:161)
    org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
    org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:889)
    org.hibernate.impl.SessionImpl.load(SessionImpl.java:808)
    org.hibernate.impl.SessionImpl.load(SessionImpl.java:801)
    com.web.UpdateWorkListAction.execute(Unknown Source)
    org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
    org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)
    org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
    org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
    org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
    before I was running a single update as below and it worked fine:
    session.beginTransaction();
    int taskId = Integer.parseInt(request.getParameter("taskId"));
    String action_taken = request.getParameter("action_taken");
    WorkListErrors worklistErrors
    = (WorkListErrors) session.load(WorkListErrors.class, new Integer(taskId));
    worklistErrors.setAction_taken(action_taken);
    session.update(worklistErrors);
    session.save(worklistErrors);
    session.getTransaction().commit();
    but when I try an an update on multiple records it does work when I have a check box checked :
    session.beginTransaction();
    int taskId = Integer.parseInt(request.getParameter("taskId"));
    String action_taken = request.getParameter("action_taken");
    WorkListErrors worklistErrors
    = (WorkListErrors) session.load(WorkListErrors.class, new Integer(taskId));
    worklistErrors.setAction_taken(action_taken);
    session.update(worklistErrors);
    session.save(worklistErrors);
    session.getTransaction().commit();
    session.beginTransaction();
    String[] tickedTaskId = request.getParameterValues("tickedTaskId");
    String[] taskId = request.getParameterValues("taskId");
    String[] action_taken = request.getParameterValues("action_taken");
    for(int i=0; i<tickedTaskId.length; i++) {
    for(int j = 0; j < taskId.length; j++) {
    if(tickedTaskId.equals(taskId[j])) {
    WorkListErrors worklistErrors
    = (WorkListErrors) session.load(WorkListErrors.class, tickedTaskId[i]);
    worklistErrors.setAction_taken(action_taken[j]);
    session.update(worklistErrors);
    session.save(worklistErrors);
    session.getTransaction().commit();
    /*Close session */
    session.close();

  • Error in Running my  Hibenate Program.............

    hi dudes........
    I am new to hibernate.......I have some errors in while Running my program using Ecllipse..
    */****Table/******
    create table student(sno number(20),sname varchar(20),mobile number(10),email varchar(20));
    Table created.
    *//****POJO class***///**
    import java.io.Serializable;
    *public class Student implements Serializable {*
    private int sno;
    private String sname;
    private long mobile;
    private String email;
    *public Student() {*
    *public int getSno() {*
    return sno;
    *public void setSno(int sno) {*
    this.sno = sno;
    *public String getSname() {*
    return sname;
    *public void setSname(String sname) {*
    this.sname = sname;
    *public long getMobile() {*
    return mobile;
    *public void setMobile(long mobile) {*
    this.mobile = mobile;
    *public String getEmail() {*
    return email;
    *public void setEmail(String email) {*
    this.email = email;
    */**ClientStudent.java***//*
    import org.hibernate.;*
    import org.hibernate.cfg.Configuration;
    *class ClientStudent {*
    *public static void main(String[] args) {*
    *try{*
    Configuration cfg= new Configuration();
    cfg.configure("/hibernate.cfg.xml");
    SessionFactory factory = cfg.buildSessionFactory();
    Session session = factory.openSession();
    Transaction tx = session.beginTransaction();
    student Sto = new student();
    Sto.setSno(1);
    Sto.setSname("saichand");
    Sto.setMobile(412171);
    Sto.setEmail("[email protected]");
    session.save(Sto);
    tx.commit();
    session.close();
    *}catch(HibernateException ex)*
    ex.printStackTrace();
    */****Hibernate.cfg.xml***/**
    *<?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">*
    *<!-- Generated by MyEclipse Hibernate Tools. -->*
    *<hibernate-configuration>*
    *<session-factory>*
    *<property name="myeclipse.connection.profile">*
    OracleEx
    *</property>*
    *<property name="connection.driver_class">*
    sun.jdbc.odbc.JdbcOdbcDriver
    *</property>*
    *<property name="connection.url">jdbc:odbc:dfi</property>*
    *<property name="connection.username">system</property>*
    *<property name="connection.password">tiger</property>*
    *<property name="dialect">*
    org.hibernate.dialect.DB2400Dialect
    *</property>*
    *<property name="show_sql">true</property>*
    *<property name="format_sql">true</property>*
    *<property name="use_sql_comments">true</property>*
    *<property name="hibernate.transaction.factory_class">*
    org.hibernate.transaction.JDBCTransactionFactory
    *</property>*
    *<property name="hibernate.connection.autocommit">*
    false
    *</property>*
    *<mapping resource="student.hdm.xml" />*
    *</session-factory>*
    *</hibernate-configuration>*
    *//**student.xml***/**
    *<?xml version="1.0" encoding="UTF-8"?>*
    *<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">*
    *<hibernate-mapping>*
    *<class name="student" table="student">*
    *<id name="sno" column="sno" type="integer">*
    *<generator class="assigned"/>*
    *</id>*
    *<property name="sname" column="sname" type="string"/>*
    *<property name="mobile" column="mobile" type="string"/>*
    *</class>*
    *</hibernate-mapping>*
    These are the two .xml files........
    While running this program i got the ERROR  ..........
    log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).*+
    log4j:WARN Please initialize the log4j system properly.*+
    Exception in thread "main" java.lang.ClassCastException: java.lang.Integer*+
    at org.hibernate.type.StringType.toString(StringType.java:44)*+
    at org.hibernate.type.NullableType.toLoggableString(NullableType.java:168)*+
    at org.hibernate.pretty.Printer.toString(Printer.java:53)*+
    at org.hibernate.pretty.Printer.toString(Printer.java:90)*+
    at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:97)*+
    at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)*+
    at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)*+
    at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)*+
    at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)*+
    at ClientStudent.main(ClientStudent.java:21)*+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    hi dudes........
    I am new to hibernate.......I have some errors in while Running my program using Ecllipse..
    ////Table/////
    create table student(sno number(20),sname varchar(20),mobile number(10),email varchar(20));
    Table created.
    POJO class
    import java.io.Serializable;
    public class Student implements Serializable {
    private int sno;
    private String sname;
    private long mobile;
    private String email;
    public Student() {
    public int getSno() {
    return sno;
    public void setSno(int sno) {
    this.sno = sno;
    public String getSname() {
    return sname;
    public void setSname(String sname) {
    this.sname = sname;
    public long getMobile() {
    return mobile;
    public void setMobile(long mobile) {
    this.mobile = mobile;
    public String getEmail() {
    return email;
    public void setEmail(String email) {
    this.email = email;
    /**ClientStudent.java***//
    import org.hibernate.;*
    import org.hibernate.cfg.Configuration;
    class ClientStudent {
    public static void main(String[] args) {
    try{
    Configuration cfg= new Configuration();
    cfg.configure("/hibernate.cfg.xml");
    SessionFactory factory = cfg.buildSessionFactory();
    Session session = factory.openSession();
    Transaction tx = session.beginTransaction();
    student Sto = new student();
    Sto.setSno(1);
    Sto.setSname("saichand");
    Sto.setMobile(412171);
    Sto.setEmail("[email protected]");
    session.save(Sto);
    tx.commit();
    session.close();
    }catch(HibernateException ex)
    ex.printStackTrace();
    /////Hibernate.cfg.xml//////
    <?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">
    <!-- Generated by MyEclipse Hibernate Tools. -->
    <hibernate-configuration>
    <session-factory>
    <property name="myeclipse.connection.profile">
    OracleEx
    </property>
    <property name="connection.driver_class">
    sun.jdbc.odbc.JdbcOdbcDriver
    </property>
    <property name="connection.url">jdbc:odbc:dfi</property>
    <property name="connection.username">system</property>
    <property name="connection.password">tiger</property>
    <property name="dialect">
    org.hibernate.dialect.DB2400Dialect
    </property>
    <property name="show_sql">true</property>
    <property name="format_sql">true</property>
    <property name="use_sql_comments">true</property>
    <property name="hibernate.transaction.factory_class">
    org.hibernate.transaction.JDBCTransactionFactory
    </property>
    <property name="hibernate.connection.autocommit">
    false
    </property>
    <mapping resource="student.hdm.xml" />
    </session-factory>
    </hibernate-configuration>
    student.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <hibernate-mapping>
    <class name="student" table="student">
    <id name="sno" column="sno" type="integer">
    <generator class="assigned"/>
    </id>
    <property name="sname" column="sname" type="string"/>
    <property name="mobile" column="mobile" type="string"/>
    </class>
    </hibernate-mapping>
    These are the two .xml files........
    While running this program i got the ERROR ..........
    log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
    log4j:WARN Please initialize the log4j system properly.
    Exception in thread "main" java.lang.ClassCastException: java.lang.Integer
    at org.hibernate.type.StringType.toString(StringType.java:44)
    at org.hibernate.type.NullableType.toLoggableString(NullableType.java:168)
    at org.hibernate.pretty.Printer.toString(Printer.java:53)
    at org.hibernate.pretty.Printer.toString(Printer.java:90)
    at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:97)
    at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:26)
    at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:985)
    at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:333)
    at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
    at ClientStudent.main(ClientStudent.java:21)

  • XML setup error when using hiberate 3.2 frame

    I am installing Eclipse+hiberate3.2+mysql5. I am trying to run the following class but some exceptions occur.
    //I am trying to run class Test
    package ch03.hibernate;
    import org.hibernate.*;
    import org.hibernate.cfg.*;
    public class Test {
         public static void main (String[] args){
              try{
                   SessionFactory sf=new Configuration().configure().buildSessionFactory();
                   Session session=sf.openSession();
                   Transaction tx=session.beginTransaction();
                   User user=new User();
                   user.setUsername("Hibernate");
                   user.setPassowrd("123");
                   session.save(user);
                   tx.commit();
                   session.close();
              }catch (HibernateException e){
                   e.printStackTrace();
    The following exceptions occur:
    log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
    log4j:WARN Please initialize the log4j system properly.
    org.hibernate.InvalidMappingException: Could not parse mapping document from resource ch03/hibernate/User.hbm.xml
         at org.hibernate.cfg.Configuration.addResource(Configuration.java:569)
         at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1587)
         at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1555)
         at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1534)
         at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1508)
         at org.hibernate.cfg.Configuration.configure(Configuration.java:1428)
         at org.hibernate.cfg.Configuration.configure(Configuration.java:1414)
         at ch03.hibernate.Test.main(Test.java:9)
    Caused by: org.hibernate.PropertyNotFoundException: field [password] not found on ch03.hibernate.User
         at org.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:112)
         at org.hibernate.property.DirectPropertyAccessor.getField(DirectPropertyAccessor.java:104)
         at org.hibernate.property.DirectPropertyAccessor.getGetter(DirectPropertyAccessor.java:127)
         at org.hibernate.util.ReflectHelper.getter(ReflectHelper.java:83)
         at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:71)
         at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:276)
         at org.hibernate.cfg.HbmBinder.createProperty(HbmBinder.java:2164)
         at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2141)
         at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:2031)
         at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:359)
         at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:273)
         at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:144)
         at org.hibernate.cfg.Configuration.add(Configuration.java:669)
         at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:504)
         at org.hibernate.cfg.Configuration.addResource(Configuration.java:566)
         ... 7 more
    I think the problem comes from the XML files. However I do not know what parts of XML are wrong. I created two xmls:
    hiberate.cfg.xml:
    <?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>
    <!-- Database connection settings -->
    <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="connection.url">jdbc:mysql://localhost:3309/MyProject</property>
    <property name="connection.username">root</property>
    <property name="connection.password">root</property>
    <!-- JDBC connection pool (use the built-in) -->
    <property name="connection.pool_size">1</property>
    <!-- SQL dialect -->
    <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
    <!-- Enable Hibernate's automatic session context management -->
    <property name="current_session_context_class">thread</property>
    <!-- Disable the second-level cache -->
    <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
    <!-- Echo all executed SQL to stdout -->
    <property name="show_sql">true</property>
    <!-- Drop and re-create the database schema on startup -->
    <property name="hbm2ddl.auto">create</property>
    <mapping resource="ch03/hibernate/User.hbm.xml"/>
    </session-factory>
    </hibernate-configuration>
    and
    User.hbm.xml :
    <?xml version="1.0" encoding='utf-8'?>
    <!DOCTYPE hibernate-mapping PUBLIC
    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <hibernate-mapping>
    <class name="ch03.hibernate.User" table="Myusertable">
    <id name="id">
    <generator class="increment"/>
    </id>
    <property name="username"/>
    <property name="password"/>
    <property name="email"/>
    </class>
    </hibernate-mapping>
    User.hbm.xml seems not to be found by hiberate.cfg.xml
    I am really appreciate that anyone can help

    Hi ,
    I met the same problem just like you met . You said you have solved the problem, and would you please tell me how to do it.
    Thank you !
    Best Regards

  • Mapping Problem using hibernate and annotations

    Hi,
    i am German student and new to hibernate. I established a mn conetction between to entities using hbm.xml mapping files. now I try to create the same connection applying annotations. unfortunately it does not work and I do not now why. First my error message followed by my classes and xml's:
    Initial SessionFactory creation failed.org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: domain.Termin.person in domain.Person.termine
    Exception in thread "main" java.lang.ExceptionInInitializerError
    at services.HibernateUtil.sessionFactory(HibernateUtil.java:39)
    at services.HibernateUtil.getSessionFactory(HibernateUtil.java:20)
    at test.Test.main(Test.java:20)
    Caused by: org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: domain.Termin.person in domain.Person.termine
    at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:552)
    at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:517)
    at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
    at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1130)
    at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:316)
    at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1286)
    at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915)
    at services.HibernateUtil.sessionFactory(HibernateUtil.java:36)
    ... 2 more
    package domain;
    import java.util.LinkedList;
    import java.util.List;
    import domain.Termin;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.ManyToMany;
    import javax.persistence.Table;
    @Entity
    @Table(name = "PERSON")
    public class Person {
       private long id;
       private String vorname;
       private String nachname;
       private List<Termin> termine=new LinkedList<Termin>();
       public Person() {
       @Id @GeneratedValue(strategy=GenerationType.AUTO)
       public long getId() {
          return id;
       public void setId(long id) {
          this.id = id;
       public String getNachname() {
          return nachname;
       public void setNachname(String nachname) {
          this.nachname = nachname;
       public String getVorname() {
          return vorname;
       public void setVorname(String vorname) {
          this.vorname = vorname;
       public void addTermin(Termin termin){
          termine.add(termin);
       @ManyToMany(mappedBy="person")
       public List<Termin> getTermine() {
          return termine;
       public void setTermine(List<Termin> termine) {
          this.termine = termine;
    package domain;
    import java.util.ArrayList;
    import java.util.List;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.ManyToMany;
    import javax.persistence.Table;
    @Entity
    @Table(name = "TERMIN")
    public class Termin {
       private long id;
       private String titel;
       private Person eigentuemer;
       private List<Person> teilnehmer= new ArrayList<Person>();
       public void addTeilnehmer(Person person){
          teilnehmer.add(person);
       @ManyToMany
       public List<Person> getTeilnehmer() {
          return teilnehmer;
       public void setTeilnehmer(List<Person> teilnehmer) {
          this.teilnehmer = teilnehmer;
       public Termin() {
       @Id @GeneratedValue(strategy=GenerationType.AUTO)
       public long getId() {
          return id;
       public void setId(long id) {
          this.id = id;
       public String getTitel() {
          return titel;
       public void setTitel(String titel) {
          this.titel = titel;
       public Person getEigentuemer() {
          return eigentuemer;
       public void setEigentuemer(Person eigentuemer) {
          this.eigentuemer = eigentuemer;
    package test;
    import org.hibernate.Session;
    import org.hibernate.SessionFactory;
    import org.hibernate.Transaction;
    import org.hibernate.cfg.Configuration;
    import org.hibernate.tool.hbm2ddl.SchemaExport;
    import services.HibernateUtil;
    import domain.Person;
    import domain.Termin;
    public class Test {
       public static void main(String[] args) {
          Session session = null;
          HibernateUtil.setRecreateDB(true);
          session = HibernateUtil.getSessionFactory().getCurrentSession();
          /*      Person person1 =new Person();
          person1.setNachname("P1");
          Transaction transaction = session.beginTransaction();
          session.save(person1);
          transaction.commit();
          Person person2 =new Person();
          person2.setNachname("P2");
          session = HibernateUtil.getSessionFactory().getCurrentSession();
          transaction = session.beginTransaction();
          session.save(person2);
          transaction.commit();
          Termin termin1 =new Termin();
          termin1.setTitel("T1");
          termin1.setEigentuemer(person1);
          termin1.addTeilnehmer(person1);
          termin1.addTeilnehmer(person2);
          session = HibernateUtil.getSessionFactory().getCurrentSession();
          transaction = session.beginTransaction();
          session.save(termin1);
          transaction.commit();
       Termin termin2 =new Termin();
          termin2.setTitel("t2");
          termin2.setEigentuemer(person1);
          termin2.addTeilnehmer(person1);
          termin2.addTeilnehmer(person2);
          transaction = session.beginTransaction();
          session.save(termin2);
          transaction.commit();
          session.close();
    package services;
    import org.hibernate.SessionFactory;
    import org.hibernate.cfg.AnnotationConfiguration;
    import domain.Person;
    import domain.Termin;
    public class HibernateUtil {
       private static boolean recreateDB = false;
       public static void setRecreateDB(boolean recreateDB) {
          HibernateUtil.recreateDB = recreateDB;
       public static SessionFactory getSessionFactory() {
          if (sessionFactory == null) {
             sessionFactory = sessionFactory("hibernate.cfg.xml");
          return sessionFactory;
       private static SessionFactory sessionFactory = null;
       private static SessionFactory sessionFactory(String configurationFileName) {
          try {
             AnnotationConfiguration annotationConfiguration =
                new AnnotationConfiguration()
                .addAnnotatedClass(Person.class)
                .addAnnotatedClass(Termin.class);
             if (recreateDB) annotationConfiguration.setProperty("hibernate.hbm2ddl.auto", "create");
             annotationConfiguration.configure();
             return annotationConfiguration.buildSessionFactory();
          } catch (Throwable ex){
             System.err.println("Initial SessionFactory creation failed." + ex);
             throw new ExceptionInInitializerError(ex);
    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE hibernate-configuration
        PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
    <hibernate-configuration>
        <session-factory >
          <property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property>
            <property name="hibernate.connection.password">application</property>
            <property name="hibernate.connection.url">jdbc:mysql://localhost/test</property>
            <property name="hibernate.connection.username">application</property>
            <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
           <property name="current_session_context_class">thread</property>
          <property name="hibernate.show_sql">true</property>
        </session-factory>
    </hibernate-configuration>

    The error message is pretty much telling you the problem:
    mappedBy reference an unknown target entity property: domain.Termin.person in domain.Person.termine
    This tells you that there's a mappedBy setting on the Person class's termine property annotation, and that the property it's referring to (the person property of the Termin class) doesn't exist.
    @ManyToMany(mappedBy="person")
    public List<Termin> getTermine() {
       return termine;
    }If we have a look at the Termin class, indeed it has the following properties:
    id
    teilnehmer
    titel
    eigentuemerAnd no person property. Remember, a property is defined by the existence of a get/set pair for the name. It's unrelated to the types returned by them and the private variables implementing them.
    mappedBy has the equivalent effect to the inverse property in a hbm.xml mapping file - it defines which entity's property will cause the foreign key value to be updated (persisting the relationship to the database). From the context of your code, I'm guessing you really want the annotation to read:
    @ManyToMany(mappedBy="teilnehmer")

  • Enqueuing JMS_TEXT_MESSAGE with Java creates strange message payload

    Hello everybody,
    I'm trying to enqueue a JMS_TEXT_MESSAGE. There is no problem doing this with PL/SQL, but with Java the payload of the enqueued message seems to contain garbage. I tried a lot but actually I have no idea why this happens.
    Here are the different user_data values of the enqueued messages:
    Java: (((; ; 0); ; ; ; ; ; ((; 100; ; ; 27); (; 200; ; 1257325532555; 24); ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; ; )); 14; ; )
    PL/SQL: ((; ; ; ; ; 0; ); 14; This is a test; )
    As you can see there are a lot of differences. The length of the string (14) is correct with Java, too, but where do the other values come from ? And what happened to the message text ?
    Environment:
    - Oracle Database 10g Enterprise Edition 10.2.0.3.0
    - JDK 1.5.0_06
    - Used libraries
    -- $ORACLE_HOME/rdbms/jlib/jmscommon.jar
    -- $ORACLE_HOME/rdbms/jlib/aqapi13.jar
    -- $ORACLE_HOME/jdbc/lib/ojdb14.jar
    -- $ORACLE_HOME/jlib/jta.jar
    This is how created the user:
    CREATE USER strm_admin IDENTIFIED BY strm_admin;
    GRANT connect, resource, aq_administrator_role TO strm_admin;
    GRANT execute on dbms_aq TO strm_admin;
    Here is the test class that creates the strange payload:
    package test;
    import javax.jms.MessageProducer;
    import javax.jms.Queue;
    import javax.jms.QueueConnection;
    import javax.jms.QueueConnectionFactory;
    import javax.jms.TextMessage;
    import oracle.AQ.AQQueueTable;
    import oracle.AQ.AQQueueTableProperty;
    import oracle.jms.AQjmsDestination;
    import oracle.jms.AQjmsDestinationProperty;
    import oracle.jms.AQjmsFactory;
    import oracle.jms.AQjmsSession;
    public class AQTest
    public static void main(String[] args) throws Exception
    String url = "jdbc:oracle:thin:@server:port:sid";
    QueueConnectionFactory qcf = AQjmsFactory.getQueueConnectionFactory(url, null);
    QueueConnection connection = qcf.createQueueConnection("strm_admin", "strm_admin");
    AQjmsSession session = (AQjmsSession)connection.createQueueSession(true, 0);
    // create queuetable
    AQQueueTableProperty tableProperty = new AQQueueTableProperty("SYS.AQ$_JMS_TEXT_MESSAGE");
    session.createQueueTable("strm_admin", "testqueuetablejms", tableProperty);
    // create queue
    AQQueueTable queueTable = session.getQueueTable("strm_admin", "testqueuetablejms");
    Queue queue = session.createQueue(queueTable, "testqueuejms", new AQjmsDestinationProperty());
    ((AQjmsDestination)queue).start(session, true, true);
    // enqueue message
    TextMessage message = session.createTextMessage();
    message.setText("This is a test");
    MessageProducer producer = session.createProducer(queue);
    producer.send(message);
    producer.close();
    // close
    session.commit();
    session.close();
    connection.close();
    With this PL/SQL the message payload is correct:
    DECLARE
    v_enqueue_options DBMS_AQ.ENQUEUE_OPTIONS_T;
    v_message_properties DBMS_AQ.MESSAGE_PROPERTIES_T;
    v_message SYS.AQ$_JMS_TEXT_MESSAGE;
    v_message_id RAW(16);
    BEGIN
    v_message := SYS.AQ$_JMS_TEXT_MESSAGE.CONSTRUCT;
    v_message.set_text('This is a test');
    DBMS_AQ.ENQUEUE (
    queue_name => 'strm_admin.testqueuejms'
    ,enqueue_options => v_enqueue_options
    ,message_properties => v_message_properties
    ,payload => v_message
    ,msgid => v_message_id
    COMMIT;
    END;
    Can anyone help me, please ? Has anyone experienced the same problem ? Or can anyone reproduce it ?
    Any help is appreciated.
    Roland

    Finally I got it fixed !
    The library "orai18n.jar" hat to be included in class path. Very strange, that there was no exception or any hint to what was missing.

Maybe you are looking for