BI current_date problem!

Hello!
We've got a strange problem: BI answers returns wrong CURRENT_DATE value when we use it in the function(on the column). On the other hand, server running with correct date and time. Does anybody know, what's wrong???
Thanks in advance.
P.S. Direct query to the database 'select current_date from dual' works fine.
Edited by: Konstantin Goryachev on Jun 18, 2012 12:10 AM

The query to the DB brings the sysdate of the the DB server, while BI answers display that of the BI server. BI and DB servers can be (and often are) installed on different boxes.

Similar Messages

  • FIle Content Conversion Problem in IDOC-XI-File Scenario

    Dear All,
    I am doing IDOC-XI-FILE scenario.
    I am facing one problem related to File Content Coversion.My requirement was to generate a dynamic file like <b>%store_code%_%current_date%_sitemaster.xml</b> , I have completed the dynamic generation successfully .
    Now there is slight change in the requirement ,<b>we have to suppress the current_date node of the xml content</b> . i have tried to suppress the current_date using these <b>DATE.fieldFixedLengths 0 , Date.fixedLengthTooShortHandling Cut</b> , But I am unable to suppress it Can some body provide me the details on this .
    The output xml version generated by Reciever file adapter is as below :
    <?xml version="1.0" encoding="UTF-8" ?>
    - <ns0:MT_SITE_MASTER xmlns:ns0="http://sample-xitest.com/sitemaster">
    - <SITE_DATA>
    <STORE_CODE>N002</STORE_CODE>
    <TITLE_MEDI>Company</TITLE_MEDI>
    <STORE_NAME>Mount Road</STORE_NAME>
    <STREET>Chennai</STREET>
    <COUNTRY>IN</COUNTRY>
    <SALES_TAX_NO>12345678910</SALES_TAX_NO>
    </SITE_DATA>
    </ns0:MT_SITE_MASTER>
    Plz provide me the code I have to write in the file content conversion .
    Thanks in advance
    Regards
    Prabhat

    If u see my earlier reply, I mentioned that u can not suppress the field from the one node.i.e Form SITE_DATA data type u can not suppress the field called CURRENT_DATE.
    My suggestion is that , modify the Data type in such a way that you will be having two nodes as I have mentioned earlier.  Then use the Suppress Logic for the Current Date.
    So it will look like this-
    <?xml version="1.0" encoding="UTF-8" ?>
    - <ns0:MT_SITE_MASTER xmlns:ns0="http://sample-xitest.com/sitemaster">
    - <SITE_DATA>
    <STORE_CODE>N002</STORE_CODE>
    <TITLE_MEDI>Company</TITLE_MEDI>
    <STORE_NAME>Mount Road</STORE_NAME>
    <STREET>Chennai</STREET>
    <COUNTRY>IN</COUNTRY>
    <SALES_TAX_NO>12345678910</SALES_TAX_NO>
    </SITE_DATA>
    <CURR_DATE>
       <CURRENT_DATE>20051105</CURRENT_DATE>
    </CURR_DATE>
    </ns0:MT_SITE_MASTER>
    So ur SITE_DATA is not having a field called CURRENT_DATE. This field is in separate node (segment ) called CURR_DATE. Now u can use the Suppress Logic for the same like this.
    CURR_DATE.fieldFixedLengths - 0
    CURR_DATE.fixedLengthTooShortHanling - Cut
    And in your Variable Substitution you can use the date from the other segment called CURR_DATE.
    Hope this solves ur problem.
    Regards,
    Moorthy

  • Null Date and Time Problem

    I created my entity classes from a database by using netbeans 6.0 and I'm using H2 as a database. I've the following table in my database.
    CREATE CACHED TABLE OPEN_TABLE ( ID INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 0) NOT NULL PRIMARY KEY, TABLE_ID INTEGER, WAITER_ID INTEGER, OPEN_HOUR TIME DEFAULT CURRENT_TIME, OPEN_DATE DATE DEFAULT CURRENT_DATE );
    and here is the entity class netbeans created for me.
    import java.io.Serializable; import java.util.Date; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; /** * * @author Yupp */ @Entity @Table(name = "OPEN_TABLE") @NamedQueries({@NamedQuery(name = "OpenTable.findById", query = "SELECT o FROM OpenTable o WHERE o.id = :id"), @NamedQuery(name = "OpenTable.findByTableId", query = "SELECT o FROM OpenTable o WHERE o.tableId = :tableId"), @NamedQuery(name = "OpenTable.findByWaiterId", query = "SELECT o FROM OpenTable o WHERE o.waiterId = :waiterId"), @NamedQuery(name = "OpenTable.findByOpenHour", query = "SELECT o FROM OpenTable o WHERE o.openHour = :openHour"), @NamedQuery(name = "OpenTable.findByOpenDate", query = "SELECT o FROM OpenTable o WHERE o.openDate = :openDate")}) public class OpenTable implements Serializable {     private static final long serialVersionUID = 1L;     @Id     @Column(name = "ID", nullable = false)     private Integer id;     @Column(name = "TABLE_ID")     private Integer tableId;     @Column(name = "WAITER_ID")     private Integer waiterId;     @Column(name = "OPEN_HOUR")     @Temporal(TemporalType.TIME)     private Date openHour;     @Column(name = "OPEN_DATE")     @Temporal(TemporalType.DATE)     private Date openDate;     public OpenTable() {     }     public OpenTable(Integer id) {         this.id = id;     }     public OpenTable(Integer id, Date openHour, Date openDate) {         this.id = id;         this.openHour = openHour;         this.openDate = openDate;     }     public Integer getId() {         return id;     }     public void setId(Integer id) {         this.id = id;     }     public Integer getTableId() {         return tableId;     }     public void setTableId(Integer tableId) {         this.tableId = tableId;     }     public Integer getWaiterId() {         return waiterId;     }     public void setWaiterId(Integer waiterId) {         this.waiterId = waiterId;     }     public Date getOpenHour() {         return openHour;     }     public void setOpenHour(Date openHour) {         this.openHour = openHour;     }     public Date getOpenDate() {         return openDate;     }     public void setOpenDate(Date openDate) {         this.openDate = openDate;     }     @Override     public int hashCode() {         int hash = 0;         hash += (id != null ? id.hashCode() : 0);         return hash;     }     @Override     public boolean equals(Object object) {         // TODO: Warning - this method won't work in the case the id fields are not set         if (!(object instanceof OpenTable)) {             return false;         }         OpenTable other = (OpenTable) object;         if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {             return false;         }         return true;     }     @Override     public String toString() {         return "OpenTable[id=" + id + "]";     } }
    The problem is when I try to insert a new OpenTable to the database, Open_Date and Open_Hour columns stay as null. I want them to get the automatic CURRENT_DATE and CURRENT_TIME values. I can't see where the problem is because I used CURRENT_DATE and CURRENT_TIME words when I created the table. I don't have any problems when I use standart SQL statements to insert a new row. I just use INSERT INTO OPEN_TABLE(TABLE_ID, WAITER_ID) VALUES(2,3) and get current date and hour values automatically but JPA doesn't do that for me. What should I do to solve the problem?

    Those database defaults are only applied when you use an INSERT statement that specifies a list of columns excluding the ones with defaults. Presumably your persistence code always sets all columns when it does an INSERT, so the defaults won't apply. You'll have to find the way to set the defaults in the persistence layer, not in the database.

  • Problem with timestamp in query

    I have problem with timestamp in JPA query.
    I wonna select all data from database where difference between two timestamps is more than 3 month.
    Database:
    ID timestamp1 timestamp2
    1 20008-11-19 15:02000 20008-08-19 15:02000
    2 20008-11-19 15:02000 20008-11-14 15:02000
    @Column(name = "timestamp1", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    public Date timestamp1;
    @Column(name = "timestamp2", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    public Date timestamp2;
    sql query works:
    select id from table where
    MONTH( DATE(timestamp1) - DATE(timestamp2) ) > 3
    but how I can write in Java?
    I't doesnt wrk:
    Query query = em.createQuery("SELECT f.id FROM Foo f WHERE MONTH( DATE(f.timestamp1) - DATE(f.timestamp2) ) > 3 ")
    error:
    ExceptionUtil E CNTR0020E: EJB threw an unexpected (non-declared) exception during invocation of method .
    Exception data: <openjpa-1.0.2-r420667:627158 nonfatal user error> org.apache.openjpa.persistence.ArgumentException: An error occurred while parsing the query filter 'SELECT f.id FROM Foo f WHERE MONTH( DATE(f.timestamp1) - DATE(f.timestamp2) ) > 3'.
    Error message: <openjpa-1.0.2-r420667:627158 nonfatal user error> org.apache.openjpa.kernel.jpql.ParseException: Encountered "MONTH (" at character 438, but expected: ["(", "+", "-", ".", ":", "", "=", "?", "ABS", "ALL", "AND", "ANY", "AS", "ASC", "AVG", "BETWEEN", "BOTH", "BY", "CONCAT", "COUNT", "CURRENT_DATE", "CURRENT_TIME", "CURRENT_TIMESTAMP", "DELETE", "DESC", "DISTINCT", "EMPTY", "ESCAPE", "EXISTS", "FETCH", "FROM", "GROUP", "HAVING", "IN", "INNER", "IS", "JOIN", "LEADING", "LEFT", "LENGTH", "LIKE", "LOCATE", "LOWER", "MAX", "MEMBER", "MIN", "MOD", "NEW", "NOT", "NULL", "OBJECT", "OF", "OR", "ORDER", "OUTER", "SELECT", "SET", "SIZE", "SOME", "SQRT", "SUBSTRING", "SUM", "TRAILING", "TRIM", "UPDATE", "UPPER", "WHERE", <BOOLEAN_LITERAL>, <DECIMAL_LITERAL>, <IDENTIFIER>, <INTEGER_LITERAL>, <STRING_LITERAL>].
    at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.parse(JPQLExpressionBuilder.java:1665)
    at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.<init>(JPQLExpressionBuilder.java:1645)

    The error is indocating improper formatting of your JPQL string. MONTH is not understood. I would recommend using your SQL string in a createNativeQuery(...) call instead.
    Doug

  • Filter for Current_Date

    I was using a a filter of:
    Scheduled Date is greater than or equal to Current_Date
    However, I noticed that some data was not included. I suspect it is because of the default time that might be included when I use this filter. Does anyone know what the default time would be?
    In any case, I think if I modified the filter to add one day to the Current_Date it would solve my problem. Does anyone know how to do this?

    Too add one day use :
    TIMESTAMPADD(SQL_TSI_DAY,1,CURRENT_DATE)
    If you think the time portion of a date you can always truncate it (reset the time , will be represented as midnight). However this will make any indexes on that column illegible by the query optimizer. Your idea of moving the current date is fine.

  • Problem with moving average

    I have to create a report which displays rolling average of revenue.
    The report contains two columns week and avg revenue. I have to display only ten weeks from the current week.
    For each week the revenue should be calculated as follows;
    weeks     actual revenue     Avg revenue
    1     10          10     
    2     20          (10+20)/2
    3     30          (10+20+30)/3     
    4     40          (10+20+30+40)/4
    5     50          (20+30+40+50)/4
    6     60          (30+40+50+60)/4
    (current week-10 weeks)
    current week
    I have used Mavg(actual revenue, 4) to calculate avg revenue.
    I am getting the correct values. However if I apply a filter say weeks between current week and (current week-10 weeks), I am facing a problem.
    My (current week-10 weeks) is now showing avg revenue as 10 which is my actual revenue amount.
    But i would like to show the revnue amount as an avgerage of (current week-10 weeks) and previous three weeks.
    The filter to limit the number of weeks is applied before calculating the moving average. Is there anyway to calculate the moving average first and then apply the week filter to report.
    Pls help me solving this.
    Thanks

    Do this:
    Have the measure as :
    case when Periods."Weekdate" > TIMESTAMPADD(SQL_TSI_WEEK, -10 , CURRENT_DATE) then MAVG ("Sales Measures".Units, 4) else 999999999 end
    And then apply filter on the above measure column as :
    Case when Periods.Weekdate > TIMESTAM... ' is not equal to / is not in 999999999
    Let us know how it goes.
    PS : To prevent runaway query, you may want filter it further by Periods."Weekdate" > TIMESTAMPADD(SQL_TSI_WEEK, -15 , CURRENT_DATE)

  • Problems with statement cache using OCI

    Hello!
    We recently changed our program to use statement cache, but we found a problem and not yet a solution.
    We have problems in this situation:
    OCIEnvCreate();
    OCIHandleAlloc();
    OCILogon2(..... OCI_LOGON2_STMTCACHE);
    OCIStmtPrepare2("CREATE TABLE db_testeSP (cod_usuario INTEGER, usuario CHAR(20), dat_inclusao DATE)")
    OCIStmtExecute();
    OCIStmtRelease(... OCI_DEFAULT);
    OCIStmtPrepare2("INSERT INTO db_testeSP (1,\'user\',CURRENT_DATE");
    OCIStmtExecute();
    OCIStmtRelease(... OCI_DEFAULT);
    OCIStmtPrepare2("SELECT * FROM db_testeSP");
    OCIStmtExecute();
    OCIStmtRelease(... OCI_DEFAULT);
    OCIStmtPrepare2("DROP TABLE db_testeSP");
    OCIStmtExecute();
    OCIStmtRelease(... OCI_DEFAULT);
    OCIStmtPrepare2("CREATE TABLE db_testeSP (cod_usuario INTEGER, usuario CHAR(20), idade INTEGER, dat_inclusao DATE)");
    OCIStmtExecute();
    OCIStmtRelease(... OCI_DEFAULT);
    OCIStmtPrepare2("INSERT INTO db_testeSP (1,\'user\',20,CURRENT_DATE");
    OCIStmtExecute();
    OCIStmtRelease(... OCI_DEFAULT);
    OCIStmtPrepare2("SELECT * FROM db_testeSP");
    OCIStmtExecute();
    OCIStmtRelease(... OCI_DEFAULT);
    On the second Select (wich is in bold), returns -1 from Execute, and if I get the error with OCIErrorGet I have: ORA-00932 - inconsistent datatypes
    Researching I discovered that this is statement cache problem, is there a way to clear the cache of one table ? I'm asking this because I could clear whenever there is a DROP TABLE or ALTER TABLE instruction (but I don't know what statements will need to be cleared from the cache). I can't clear all the cache because I may have other statements from other tables on the cache.
    This situation above is just an example, but I think that this will cause other problems too.
    Our program is a gateway from the main program and database, so I don't know the SQL instructions before executing. How can we resolve this problem?
    I have tested this issue with Oracle 10g (10.2.0.4.0) and 11g (11.2.0.1.0) both 64 bits and the result is the same (the OCI is version 11.2.0).
    We appreciate any help.
    Thanks in advance,
    Daniel

    After long time searching for answers, apparently this is expected to happen and the program should not use Statement caching in this situation.
    I found this on an Oracle document (Tuning Data Source Connection Pools - 11g Release 1 (10.3.6)) and we will need to review the use of statement caching.
    Stay as a tip for others who might be in the same situation.

  • Problem with Date difference in OBIEE

    Hi,
    OBIEe- 10.1.3.4
    My exp: Beginner in OBIEE
    I have a requirement to calculate a policy age with the date columns from a policy table these are.
    The columns involved are as below:
    1. policy_effective_date alias EFD
    2.policy_start_date alias STD
    3.policy_expiry_date alias EXD
    so my functionality is based as below
    Policy Age = (CASE WHEN EFD > sysdate THEN trunc( months_between( STD, sysdate ) /12 )
    ELSE trunc( months_between(EXD, STD) /12 ) END)
    I have implemented the same in OBIEE as
    Policay Age= CASE WHEN CAST (EFD AS TIMESTAMP ) >
    CURRENT_DATE THEN TIMESTAMPDIFF( SQL_TSI_YEAR , CAST (STD AS TIMESTAMP ), CURRENT_DATE ) ELSE TIMESTAMPDIFF( SQL_TSI_YEAR , CAST (STD AS TIMESTAMP ),
    CAST (EXD AS TIMESTAMP )) END
    PROBLEM!!!!: I am having the following data in the database
    EFD=06-OCT-05
    STD=06-OCT-99
    EXD=06-OCT-06
    Ideally the answer should be 7 years that is 2006-1999= 7 years but instead it gives "-93 years " thats because it does a 06-99 =-93 years.
    Please can anyone suggest where and what Date conversion can I use in the OBIEE formula??

    Try with extract year from (date column ) , it may solve your problem...

  • Problem interface having only target datastore without source

    Hi,
    I have created an interface,there is no source my target is oracle table.
    This table is having columns like..
    current_date,load_cycle_id etc.
    For current date in mapping i wrote 'select sysdate from dual' or 'sysdate'
    For load_cycle_id = database sequence is mapped like
    <schemaname>.<seq_name>.nextval
    But it is not working properly,
    In the operator select query doesn't have the from clause table value because of this it is resulting in an error.I manually added dual in that it is working.
    plz let me know how to create interface without source datastore and necessary setting required.
    <schemaname>.<seq_name>.currval it is also not working,it is giving error like
    "not defined in this session"
    plz let me know how to solve these problems
    Thanks,
    Jai
    and in one more interface if i want to use current value of the sequence i wrote

    I have created file_id_seq in database.
    In my first interface i have only target datastore.I have two fileds,like
    Load_cycle_id: Mapping--> <schema>.<seq_name>.nextval
    log_date : Mapping--> sysdate
    when I saw the query generated by the Odi in operator description tab
    selec ..
    from <table name is missing>
    in from clause i manually added dual ,and restarted the session then it was done.
    Its problem with query generated by the ODI.
    I changed in mappin as "select sysdate from dual" like that still i didn't get.
    After loading this interface by manually editing ,I created one more interface,
    in that one more filed is there which requires current value of the sequence used in above interface.In mapping i wrote <schema>.<seq_name>.curr_val Its resulting in an error like "sequence current value is not defined in this current session"
    plz help me
    Jai

  • Problem in deleting Rows of JTable after sorting it

    Hi all,
    I'm getting problems in Removing Row(s) after sorting a JTable.
    Please find the code snippets at this URL. Thanks for your time...
    http://forum.java.sun.com/thread.jsp?forum=31&thread=459736&start=15&range=15&hilite=false&q=

    Hi Abhijeet,
    I tried it the way you said using
         wdContext.nodeBirhtday_List().nodeItab().moveFirst();
         //     loop backwards to avoid index troubles
         for (int i = n - 1; i >= 0; --i)
              current_date  = wdContext.nodeBirhtday_List().nodeItab().currentItabElement().getGbdat().getDate();
              current_month = wdContext.nodeBirhtday_List().nodeItab().currentItabElement().getGbdat().getMonth();
              if (( current_date != date_today ) && ( current_month != month_today ))
                   wdContext.nodeBirhtday_List().nodeItab().removeElement(wdContext.nodeBirhtday_List().nodeItab().
                                  getElementAt(i));                
              wdContext.nodeBirhtday_List().nodeItab().moveNext();     
    It adds records...
    According to Valerys Solution, the IPrivate<CustomController> doesnt show me the required nodes. and gives me 'Unable to resolve' error.
    Can you please suggest where I am going wrong
    Regards
    Abdullah

  • JHS-00114: Date $CURRENT_DATE$ must be of format MM-dd-yyyy

    I am using jheadstart 10.1.2.2(build 32) in jdeveloper 10.1.2.1.0(build 1913).
    I need to display current date for a date field as a default value when inserting new rows.
    I set $CURRENT_DATE$ in default display value for that date field. The default value(todays date) is displayed only on a tabel(multi row insert is allowed) and on a form(single row insert) I get the above error JHS-00114: Date 2007-01-02 14:18:37.0 must be of format MM-dd-yyyy.
    The problem with multirow insert on a table even though it displays default value is user has to fill in other mandatory fields in the row since jheadstart thinks that user already started entering new row.
    It's ok for me if the default value is displayed properly on either table or form.
    Thanks for any help.
    Lavanya.

    Whenever you are in PM:
    sys@sid1> l
    1* select to_char(sysdate, 'MM/DD/YYYY HH12:MI:SS AM') from dual
    sys@sid1> /
    TO_CHAR(SYSDATE,'MM/DD
    07/09/2007 01:22:48 PM
    1 row selected.
    My time is 1:22:48 PM here. Even though I put AM in the to_char format, it noticed it was PM and changed it.

  • Date format Problem in OAF R12 Urgent Please help!!!

    We have acustom application in OAF which was developed in 11i. Now we migrated the same to R12.
    In this there are two date fileds getting dispayed on the page and the query for the same is
    SELECT TO_CHAR (SYSDATE, 'dd-mm-yyyy') AS CURRENT_DATE, UPPER (TO_CHAR (SYSDATE - 10, 'mon-yy')) AS g_period, UPPER (TO_CHAR (SYSDATE + 5, 'mon-yy')) AS gnext_period, TO_CHAR (sysdate,'dd-mon-yyyy') as today_date, TO_CHAR (sysdate - 1,'dd-mon-yyyy') as yesterday_date FROM DUAL
    In 11i version the output is dispaying correctly but in R12 the current date is dispayed as
    Start Date 04-Nov-5242
    End Date 04-Nov-5241
    As per logic it should be
    Start Date 09-Feb-2012
    End Date 10-Feb-2012
    Please help..Urgent issue.

    Here are the answers to your problems :
    1. Once u restart , the oracle services and the database is not mounting automatically.That is because, when you install the Oracle Oracle8i Standard Edition Release (8.1.7), the two key services namely
    OracleOraHome81TNSListner and
    OracleService<your SID name>
    are configured as manual start ( check the NT --> start>setting>control panel>services. )
    For the database to start automatically the next time you start your machine, these two services will have to be put into "Automatic Start" mode.
    < for this double click on the respective service, select the "Automatic" radio button and click on ok>.
    Now when you restart the machine, your database will be automatically mounted.
    2. this as explained above is a corollory to the above problem. you can start or stop your database on NT using the "Services" window....
    hope this helps.
    bye.
    Hi All,
    I have installed Oracle Oracle8i Standard Edition Release (8.1.7) from technet site.
    I have installed it on windows NT 4.0 .
    Installation is fine.
    I can access or get into SQL prompt .
    I have created a database also.
    1st problem
    My problem is once I restart the Machine and try to access SQL plus .it gives me an error
    ORA-01034: Oracle not available
    ORA-27101: shared memory realm does not exist.
    2nd problem
    I dont know how to start and stop the database , as there is nothing to do that in the start menu of Oracle .
    How do i do this .
    This is very urgent please help.
    regards,
    Preeti

  • BFILE Problem

    Hello,
    The problem that i have is that i want to insert a file residing in the network into the oracle database into a blob field and again read it from the database and show it ie either insert it into a file directly and then open it using the correct editor or open it directly. I am using java along with it but i am basically stuck on the database side.
    I am sending the code which i have written till date
    i basically need to know
    1)the syntax i am using to interact with the database is right ie where is the error in the code
    2)provided that is ok whether my overall code is on the right track.
    After line control 10
    The error message i am getting:
    java.sql.SQL Exception:ORA-22288:file operation fileopen failed
    LFI:00108:open expect the file[map][gif] to exist
    ORA-0615:at"SYS.DBMS_LOB",line 370
    ORA-0615:at line 1
    My developopment enviornment is JDeveloper3.0 as this code is having problems compiling in JDK as Jdeveloper overides a few of the jdk classes.
    =========================================================================
    My table structure
    CREATE TABLE DOC_MAS(
    DOC_MAS_SR_NO NUMBER(10),
    PROJECT_NAME VARCHAR2(30),
    MODULE_NO NUMBER(10),
    DOC_NAME VARCHAR2(10),
    DOC_TYPE VARCHAR2(10),
    VERSION NUMBER(10));
    CREATE SEQUENCE SEQ_DOC_MAS START WITH 1 INCREMENT BY 1;
    CREATE SEQUENCE SEQ_DOC_DETAIL START WITH 1 INCREMENT BY 1;
    CREATE TABLE DOC_DETAIL(
    DOC_DETAIL_SR_NO NUMBER(10),
    DOC_MAS_SR_NO NUMBER(10),
    DATE_OF_INSERT DATE,
    ACTUAL_DOC BFILE,
    COMMENTS VARCHAR2(500));
    ===============================================================================
    My connection code:
    public class ConnectionParams {
    // The machine on which the database resides
    //public final static String s_hostName = "insn110a.in.oracle.com";
    public final static String s_hostName = "192.168.1.1";
    // The TNS listener port
    public final static String s_portNumber = "1521";
    // The database name (SID)
    //public final static String s_databaseSID = "otndb";
    public final static String s_databaseSID = "orcl";
    // The database User ID
    public final static String s_userName = "scott";
    // The database user password
    public final static String s_password = "tiger";
    ========================================================================================
    import java.io.*;
    import java.sql.*;
    import oracle.sql.*;
    import oracle.jdbc.driver.*;
    import java.util.*;
    import java.util.Date;
    //import java.math.BigDecimal;
    public class Sample3
    int size;
    Connection m_connection; //Database Connection Object
    String p_doc_name=null;
    String s_blobvariable = p_doc_name;
    String file_path = null;
    byte b[];
    String l_dirPath;
    public Sample3()
    dbConnection();
    public static void main(String[] args)
    Sample3 lobs = new Sample3();
    // lobs.dbConnection();
    lobs.readFileNameExt();
    /*This class is for creation of connection =========================================*/
    public void dbConnection() {
    try {
    DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    String l_dbConnectString =
    "(DESCRIPTION=(ADDRESS=(HOST="+ConnectionParams.s_hostName+")"+
    "(PROTOCOL=tcp)(PORT="+ConnectionParams.s_portNumber+"))"+
    "(CONNECT_DATA=(SID="+ConnectionParams.s_databaseSID+")))";
    m_connection = DriverManager.getConnection(
    "jdbc:oracle:thin:@"+l_dbConnectString,
    ConnectionParams.s_userName, ConnectionParams.s_password);
    m_connection.setAutoCommit(false);
    System.out.println("Connection Successful");
    Thread.sleep(3000);
    } catch(Exception ex){ //Trap SQL errors
    System.out.println("Error in Connecting to the Database "+ex.toString());
    /*========================================================================================
    File inserting section of the code
    // THIS class gets the input from the file dialog box it gets the file path,projectName and the module no
    //public void readFileNameExt(String p_doc_path,String p_module_no,String p_project_name)
    public void readFileNameExt()
    String p_doc_path = "c:/warea/Mehul2/map.gif";
    int p_module_no = 10;
    String p_project_name = "Finserve";
    String p_doc_type= null;
    String p_version = null;
    StringTokenizer strtkn = new StringTokenizer(p_doc_path,"/");
    while(strtkn.hasMoreTokens())
    p_doc_name =strtkn.nextToken();
    System.out.println("The file name is" +p_doc_name);
    s_blobvariable = p_doc_path;
    StringTokenizer strtoken = new StringTokenizer(p_doc_name,".");
    while(strtoken.hasMoreTokens())
    p_doc_type =strtoken.nextToken();
    try{
    System.out.println("The file Type is"+p_doc_type);
    insertDocMas(p_doc_path,p_doc_name,p_doc_type,p_project_name,p_module_no);
    Thread.sleep(10000);
    }catch (Exception e){}
    }//end of method
    //============================================== this class is for inserting the doc_mas details in teh table along with version checking
    public void insertDocMas(String p_doc_path,String p_doc_name,String p_doc_type,String p_project_name,int p_module_no){
    int p_version = -1;
    int p_doc_mas_sr_no = -1;
    // String verision=null;
    int verision;
    String s = null;
    try{
    Statement l_stmt = m_connection.createStatement();
    ResultSet l_version_details = l_stmt.executeQuery("SELECT MAX(VERSION) FROM DOC_MAS WHERE DOC_NAME = '"+p_doc_name+"'");
    if (l_version_details.next())
    { System.out.println("The Control 1");
    verision = l_version_details.getInt(1);
    System.out.println("The Control 2 : "+verision);
    verision = verision +1;
    else {
    verision = 1;
    System.out.println("The Control 3");
    p_version = verision;
    // System.out.println("The value of p_version" + p_version);
    l_version_details.close();
    l_stmt.close();
    Thread.sleep(4000);
    }catch(Exception e){
    System.out.println("Exception has occured at the time of insert"+e);
    System.out.println("The value of p_version" + p_version);
    /* try{
    Statement stmt = m_connection.createStatement();
    ResultSet rset = stmt.executeQuery("select DEPTNO,DNAME,LOC from DEPT");
    while(rset.next()){
    BigDecimal deptno = rset.getBigDecimal(1,2);
    String dname = rset.getString(2);
    // Timestamp hiredate = rset.getTimestamp(3);
    String loc = rset.getString(3);
    System.out.println(deptno+" "+dname+" "+loc);
    Thread.sleep(50000);
    }catch(Exception e){System.out.println(e);}
    try{
    Statement l_stmt = m_connection.createStatement();
    ResultSet l_seq_details = l_stmt.executeQuery("SELECT SEQ_DOC_MAS.NEXTVAL FROM DUAL");
    if (l_seq_details.next())
    p_doc_mas_sr_no = l_seq_details.getInt(1);
    System.out.println("The Control AA");
    System.out.println("The value of p_doc_mas_sr_no" + p_doc_mas_sr_no);
    l_seq_details.close();
    l_stmt.close();
    Thread.sleep(4000);
    }catch(Exception e){
    System.out.println("Exception has occured at the time of selecting the current sequence number"+e);
    try {
    System.out.println("Creating rows in DOC_MAS.. ");
    System.out.println("The Control VV");
    PreparedStatement l_pstmt = m_connection.prepareStatement("insert into DOC_MAS(DOC_MAS_SR_NO,PROJECT_NAME,MODULE_NO,DOC_NAME,DOC_TYPE,VERSION) values(?,?,?,?,?,?)");//SEQ_DOC_MAS.nextval
    l_pstmt.setInt(1,p_doc_mas_sr_no);//"SEQ_DOC_DETAIL.NEXTVAL"
    l_pstmt.setString(2,p_project_name);
    l_pstmt.setInt(3,p_module_no);
    l_pstmt.setString(4,p_doc_name);
    l_pstmt.setString(5,p_doc_type);
    l_pstmt.setInt(6,p_version);
    l_pstmt.executeUpdate(); // Execute SQL statement
    l_pstmt.close();
    System.out.println("The Control 3");
    // Close statement
    //Thread.sleep(20000);
    }catch(Exception e){
    System.out.println("Exception has occured at the time of insert11"+e);
    try{System.out.println("The Control 4");
    Statement l_statement = m_connection.createStatement();
    ResultSet l_doc_mas_sr_no = l_statement.executeQuery(
    "SELECT max(DOC_MAS_SR_NO) FROM DOC_MAS "+
    "WHERE DOC_NAME = '"+p_doc_name+"' ");//FOR UPDATE
    if (l_doc_mas_sr_no.next())
    p_doc_mas_sr_no = l_doc_mas_sr_no.getInt(1);
    l_doc_mas_sr_no.close();
    l_statement.close();
    System.out.println("The Control 5");
    //Thread.sleep(10000);
    }catch(Exception e){
    System.out.println("Exception has occured at the time of insert");
    loadSamples(p_version,p_doc_path,p_project_name,p_doc_mas_sr_no,p_doc_name,p_doc_type);
    }//Method insertDocMas() closing here
    /*This class is for loading the data into the database==================================*/
    public void loadSamples(int p_version, String p_doc_path,String p_project_name,int p_doc_mas_sr_no,String p_doc_name,String p_doc_type) {
    int p_doc_detail_sr_no = -1;
    //Date p_sysdate = new Date() ;
    try{
    Statement l_stmt = m_connection.createStatement();
    ResultSet l_seq_doc_details = l_stmt.executeQuery("SELECT SEQ_DOC_DETAIL.NEXTVAL FROM DUAL");
    if (l_seq_doc_details.next())
    p_doc_detail_sr_no = l_seq_doc_details.getInt(1);
    System.out.println("The Control AA");
    System.out.println("The value of p_doc_detail_sr_no" + p_doc_detail_sr_no);
    l_seq_doc_details.close();
    l_stmt.close();
    Thread.sleep(4000);
    }catch(Exception e){
    System.out.println("Exception has occured at the time of selecting the current sequence number"+e);
    try {System.out.println("The Control 6");
    java.sql.Date current_date = new java.sql.Date(System.currentTimeMillis());
    System.out.println("Creating row for actual-doc in DOC_DETAILS.. ");
    //PreparedStatement l_pstmt = m_connection.prepareStatement("insert into DOC_DETAIL(DOC_DETAIL_SR_NO,DOC_MAS_SR_NO,DATE_OF_INSERT,ACTUAL_DOC)values(?,?,'"+current_date+"', empty_blob() )");
    PreparedStatement l_pstmt = m_connection.prepareStatement("insert into DOC_DETAIL(DOC_DETAIL_SR_NO,DOC_MAS_SR_NO,DATE_OF_INSERT)values(?,?,?)");
    l_pstmt.setInt(1,p_doc_detail_sr_no);
    l_pstmt.setInt(2,p_doc_mas_sr_no);
    l_pstmt.setDate(3,current_date);
    System.out.println("The Control 6AA");
    l_pstmt.execute(); // Execute SQL statement
    l_pstmt.close(); // Close statement
    System.out.println("Created.\nLoading <map.gif> into BLOB column for doc_detail...");
    System.out.println("The Control 7");
    // Retrieve the row just inserted, and lock it for insertion of the
    }catch(Exception e){
    System.out.println("Exception has occured at the time of inserting blob locators"+e);
    try {
    System.out.println("The Control 8");
    l_dirPath = p_doc_path ;
    PreparedStatement l_pstmt = m_connection.prepareStatement(
    "CREATE OR REPLACE DIRECTORY BFILEDIR AS '" + l_dirPath + "' ");
    l_pstmt.execute();
    l_pstmt.close();
    // Execute the prepared SQL Statement
    } catch (Exception ex)
    { // Trap SQL errors
    System.out.println("Error loading sample files ");
    System.out.println("\n"+ex.toString());
    System.out.println("The Control 8AA");
    try{
    // Insert the Image as a BFILE Column
    // String abc = new String("INSERT INTO DOC_DETAIL(ACTUAL_DOC)VALUES(BFILENAME('BFILEDIR2','" + p_doc_name + "')) WHERE D0C_MAS_SR_NO = '" + p_doc_mas_sr_no + "';");
    //System.out.println(abc);
    //l_pstmt.executeQuery("insert into DOC_DETAIL(ACTUAL_DOC)values(BFILENAME('BFILEDIR','" + p_doc_name + "')) where D0C_MAS_SR_NO = '" + p_doc_mas_sr_no + "';");
    String abc = new String("update DOC_DETAIL SET ACTUAL_DOC = BFILENAME('BFILEDIR','" + p_doc_name + "') where D0C_MAS_SR_NO = '"+p_doc_mas_sr_no+"' ");
    System.out.println(abc);
    PreparedStatement l_pstmt = m_connection.prepareStatement("update DOC_DETAIL SET ACTUAL_DOC = BFILENAME('BFILEDIR','" + p_doc_name + "') where DOC_MAS_SR_NO = '"+p_doc_mas_sr_no+"' ");
    l_pstmt.executeQuery();
    l_pstmt.close(); // Close the prepared Statement
    drawBLOB(p_version,p_doc_mas_sr_no,p_project_name,p_doc_name, p_doc_type);
    System.out.println("The Control 9");
    } catch (Exception ex)
    { // Trap SQL errors
    System.out.println("Error loading sample files ");
    System.out.println("\n"+ex.toString());
    }//Method closes here
    * Retrieve the BLOB data from input BLOB column into a local file,
    * and draws the image. The file type needs to be added here
    public void drawBLOB(int p_version,int p_doc_mas_sr_no,String p_project_name, String p_doc_name,String p_doc_type) {
    //String fileType this should be passed at some point to ensure that th e file gets the right extension
    try { System.out.println("The Control 10");
    Statement l_stmt = m_connection.createStatement();
    // Execute the Query and get BFILE Locator as a result set
    ResultSet l_rset = l_stmt.executeQuery("Select ACTUAL_DOC from DOC_DETAIL WHERE DOC_MAS_SR_NO= '"+p_doc_mas_sr_no+"' ");
    //Note : Using Oracle Extension oracle.sql.BFILE to get BFILE Locator
    oracle.sql.BFILE l_bfile = null;
    // Loop through the Result Set
    while(l_rset.next()) {
    l_bfile = ((OracleResultSet)l_rset).getBFILE(1); // Get the BFILE Locator
    System.out.println("Retrieved BFILE Locator..");
    System.out.println("l_bfile :"+l_bfile);
    l_rset.close(); // Close the ResultSet
    l_stmt.close(); // Close the Statement
    // Open the file with openFile Method of oracle.sql.BFILE class
    l_bfile.openFile();
    // Open the Input Binary Stream with getBinaryStream method of
    // oracle.sql.BFILE class
    InputStream f = l_bfile.getBinaryStream();
    System.out.println("Opened Binary Stream ...");
    size =f.available();
    System.out.println("Actual Size:"+size+"Bytes");
    int n = size;
    int x=0;
    System.out.println("First"+n+"bytes of the file one can read at a time");
    b = new byte[size];
    System.out.println("printing bytes"+b);
    char ch=' ';
    while(x<size)
    ch=(char)f.read();
    b[x]=(byte)ch;
    //str+=ch;
    x++;
    System.out.println("The Control 11");
    // file_path = "c:/warea/mehul/Project/"+p_project_name+"/"+p_doc_name;
    directoryMap( p_version, p_project_name, p_doc_name);//This method is called here
    OutputStream fout = new FileOutputStream(file_path);
    for(int i=0;i<b.length;i +=2)
    //out.println(b);
    fout.write(b[i]);
    System.out.println("The Control 12");
    drawMap(file_path,p_doc_name,p_doc_type);
    } catch (Exception ex) { // Trap SQL and IO errors
    System.out.println("Error in retrieving and drawing map for selected airport");
    System.out.println("\n"+ex.toString());
    * Create a label from the image filepassed, add the label to the image area
    This part will have to be modified majorly
    public void drawMap(String file_path, String p_doc_name,String p_doc_type)
    //Refer to SIRExtOpen.java
    System.out.println("The Control 13");
    Runtime r = Runtime.getRuntime();
    Process p = null;
    if (p_doc_type.equals("html")&#0124; &#0124;p_doc_type.equals("htm"))
    try{
    p = r.exec( "C:\\Program Files\\Internet Explorer\\Iexplore.EXE " +file_path);
    //repaint();
    p.waitFor();
    catch(Exception ex)
    ex.printStackTrace();
    System.out.println(ex);
    System.out.println(ex.getMessage());
    if(p_doc_type.equals("txt")&#0124; &#0124; p_doc_type.equals("sql")&#0124; &#0124; p_doc_type.equals("java"))
    try
    p = r.exec( "C:\\WINDOWS\\notepad.EXE " + p_doc_name); p.waitFor();
    catch(Exception ex)
    ex.printStackTrace();
    System.out.println(ex);
    System.out.println(ex.getMessage());
    } // end of txt , sql , java if
    if(p_doc_type.equals("xls"))
    try
    p = r.exec( "C:\\Program Files\\Microsoft Office\\Office\\excel.EXE " +file_path);
    p.waitFor();
    catch(Exception ex)
    ex.printStackTrace();
    System.out.println(ex);
    System.out.println(ex.getMessage());
    } // end of xls if
    if(p_doc_type.equals("fmb"))
    try
    p = r.exec( "C:\\Program Files\\Accessories\\wordpad.exe " + file_path);p.waitFor();
    catch(Exception ex)
    ex.printStackTrace();
    System.out.println(ex);
    System.out.println(ex.getMessage());
    } // end of fmb if
    if(p_doc_type.equals("doc"))
    try
    p = r.exec( "C:\\Program Files\\Accessories\\wordpad.exe " + file_path);p.waitFor();
    catch(Exception ex)
    ex.printStackTrace();
    System.out.println(ex);
    System.out.println(ex.getMessage());
    } // end of doc if
    if(p_doc_type.equals("mpp"))
    try
    p = r.exec( "C:\\Program Files\\Accessories\\wordpad.exe " + file_path);p.waitFor();
    catch(Exception ex)
    ex.printStackTrace();
    System.out.println(ex);
    System.out.println(ex.getMessage());
    } // end of mpp if
    //Here you can write a statement for deleting the file in the root directory once the file is opened using any editor
    }//end of method
    * This method is called when a row is selected from the combo.
    * It checks if there exists data in DOC_DETAIL for the selected
    * file. If there exists data, it calls drawBLOB and writeCLOB to
    * display the data
    /*public void fileSelected(String p_doc_mas_sr_no,String p_doc_name,String p_doc_type) {
    try {
    System.out.println("Retrieving LOB details for selected file..");
    // Create a SQL statement
    Statement l_stmt = m_connection.createStatement();
    // Query DOC_DETAILS for the selected file
    java.sql.ResultSet l_lobDetails = l_stmt.executeQuery(
    "SELECT ACTUAL_DOC FROM DOC_DETAILS "+
    "WHERE DOC_MAS_SR_NO='"+p_doc_mas_sr_no+"'");
    // Check if LOB columns exist
    if (l_lobDetails.next()) {
    // LOB details exist
    // Display airport map and suggestion book (LOB details)
    drawBLOB(l_lobDetails.getBlob(1),p_doc_name,p_doc_type);
    //lobs.drawBLOB(((OracleResultSet)l_lobDetails).getBLOB(1),p_doc_name,p_doc_type);
    //Should this be like this
    System.out.println("Done retrieving and displaying LOB details");
    } else {
    // No LOB details
    // m_GUI.m_loadButton.setEnabled(true);
    //TO BE CHECKED OUT LATER m_loadButton This is a button in the form
    System.out.println("No airport map and suggestion book exist for selected airport");
    System.out.println("\nPress <Load Sample3 Files> to load LOB details");
    l_lobDetails.close();
    l_stmt.close();
    } catch (Exception ex) { // Trap SQL errors
    System.out.println("Error retrieving LOB Details for the selected airport");
    System.out.println(ex.toString());
    public void directoryMap(int p_version,String p_project_name,String p_doc_name) {//start of the method
    System.out.println("The Control 14");
    if (p_version==1)
    File f = new File("c:/warea/mehul/Project/"+p_project_name+"/"+p_version);
    if(f.exists())
    file_path = "c:/warea/mehul/Project/"+p_project_name+"/"+p_version+"/"+p_doc_name;
    else
    File f1 = new File("c:/warea/mehul/Project/"+p_project_name+"/"+p_version);
    file_path = "c:/warea/mehul/Project/"+p_project_name+"/"+p_version+"/"+p_doc_name;
    }//end of inner else
    }//end of else
    else if(p_version==2)
    File f = new File("c:/warea/mehul/Project/"+p_project_name+"/"+p_version);
    if(f.exists())
    file_path = "c:/warea/mehul/Project/"+p_project_name+"/"+p_version+"/"+p_doc_name;
    else
    File f1 = new File("c:/warea/mehul/Project/"+p_project_name+"/"+p_version);
    file_path = "c:/warea/mehul/Project/"+p_project_name+"/"+p_version+"/"+p_doc_name;
    }//end of inner else
    }//end of else
    else if(p_version==3)
    File f = new File("c:/warea/mehul/Project/"+p_project_name+"/"+p_version);
    if(f.exists())
    file_path = "c:/warea/mehul/Project/"+p_project_name+"/"+p_version+"/"+p_doc_name;
    else{
    File f1 = new File("c:/warea/mehul/Project/"+p_project_name+"/"+p_version);
    file_path = "c:/warea/mehul/Project/"+p_project_name+"/"+p_version+"/"+p_doc_name;
    }//end of inner else
    }//end of outer else
    else
    System.out.println("System has gone into 4th version");
    }//end of method
    }//end of class
    null

    Hi
    Have you found a workaround for this problem? im having a similiar problem and am interested in its solution.....

  • Persist problem in cascade using @OneToMany

    We are trying to persist an object which has a OneToMany relationship to other objects with CascadeType.ALL
    When we persist, the log shows that it creates the INSERT statement with the correct bind variables (sequence-generated REPORT_ID, etc.) for the first object.
    The problem happens when it tries to cascade and insert the Many part. The log shows the it tries to create the INSERT statement for the second object but the bind variable for the REPORT_ID is null.
    Since we defined the relationship of the OneToMany using the REPORT_ID, we assumed that the REPORT_ID that was auto-generated for the first object would be used for the @Many objects.
    What are we missing ??????
    First Object:
    @Id
    @SequenceGenerator(name = "REPORT_HEADER_S", initialValue = 1, allocationSize = 1)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "REPORT_HEADER_S")
    @Column(name = "REPORT_ID", nullable = false)
    private Long reportId;
    @OneToMany(mappedBy = "report", cascade = { CascadeType.ALL})
    private List<Summary> summaryList;
    Second Object
    @ManyToOne
    @JoinColumn(name = "REPORT_ID", referencedColumnName = "REPORT_ID")
    private Report report;

    Hello, Chris.
    Thank you for your reply.
    The structure of my tables is:
    table document (id int not null constraint document_pk primary key,
    table document_price (document_id int not null constraint document_price_fk references document (id),
    date date not null default current_date,
    price decimal(9,2) not null,
    primary key (document_id, date)).
    The entity classes are:
    @Entity @Table(name = "DOCUMENT")
    public class Document implements Serializable {
    @TableGenerator(name = "document_generator", table = "ID_GENERATION", pkColumnName = "TABLE_NAME", valueColumnName = "ID_VALUE",
    pkColumnValue = "DOCUMENT", allocationSize = 1)
    @Id
    @GeneratedValue(generator = "document_generator")
    @Basic(optional = false)
    @Column(name = "ID")
    private Integer id;
    // other fields
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "document", fetch = FetchType.LAZY)
    private Collection<DocumentPrice> documentPriceCollection;
    // constructors, getters, setters ...
    @PostPersist
    public void initializePrices() {
    for (DocumentPrice dp : documentPriceCollection) {
    dp.documentPricePK.setDocumentId(id);
    @Entity
    @Table(name = "DOCUMENT_PRICE")
    public class DocumentPrice implements Serializable {
    @EmbeddedId
    protected DocumentPricePK documentPricePK;
    @Basic(optional = false)
    @Column(name = "PRICE")
    private BigDecimal price;
    @JoinColumn(name = "DOCUMENT_ID", referencedColumnName = "ID", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Document document;
    // constructors, getters, setters ...
    @Embeddable
    public class DocumentPricePK implements Serializable {
    @Basic(optional = false)
    @Column(name = "DOCUMENT_ID")
    private int documentId;
    @Basic(optional = false)
    @Column(name = "DATE")
    @Temporal(TemporalType.DATE)
    private Date date;
    // constructors, getters, setters ...
    I create first Document entity, create DocumentPrice entity and add DocumentPrice entity to the documentPriceCollection of the first Document entity. I invoke commit method of my entity manager, and corresponding rows are added to the document and document_price tables.
    I invoke clear method of my entity manager.
    Then I create new entities Document and DocumentPrice and add new DocumentPrice entity to the documentPriceCollection of the new Document entity. I invoke commit method and get the following exception:
    oracle.toplink.essentials.exceptions.ValidationException
    Exception Description: Cannot persist detached object [entities.DocumentPrice[documentPricePK=.entities.DocumentPricePK[documentId=0;
    date=Sat May 29 00:00:00 MSD 2010];
    price=11]].
    Class> entities.DocumentPrice Primary Key> [2010-05-29, 0]
    at oracle.toplink.essentials.exceptions.ValidationException.cannotPersistExistingObject(ValidationException.java:2171)
    at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.registerNotRegisteredNewObjectForPersist(UnitOfWorkImpl.java:3251)
    at oracle.toplink.essentials.internal.ejb.cmp3.base.RepeatableWriteUnitOfWork.registerNotRegisteredNewObjectForPersist(RepeatableWriteUnitOfWork.java:339)
    at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.registerNewObjectForPersist(UnitOfWorkImpl.java:3220)
    at oracle.toplink.essentials.mappings.CollectionMapping.cascadeRegisterNewIfRequired(CollectionMapping.java:265)
    at oracle.toplink.essentials.internal.descriptors.ObjectBuilder.cascadeRegisterNewForCreate(ObjectBuilder.java:1294)
    at oracle.toplink.essentials.internal.sessions.UnitOfWorkImpl.registerNewObjectForPersist(UnitOfWorkImpl.java:3226)
    at oracle.toplink.essentials.internal.ejb.cmp3.base.EntityManagerImpl.persist(EntityManagerImpl.java:205)
    And I see through debugging that @PostPersist method of the Document entity isn't invoked during second commit before the exception is generated.
    What should I do to avoid exception during second commit?

  • A problem with threads

    I am trying to implement some kind of a server listening for requests. The listener part of the app, is a daemon thread that listens for connections and instantiates a handling daemon thread once it gets some. However, my problem is that i must be able to kill the listening thread at the user's will (say via a sto button). I have done this via the Sun's proposed way, by testing a boolean flag in the loop, which is set to false when i wish to kill the thread. The problem with this thing is the following...
    Once the thread starts excecuting, it will test the flag, find it true and enter the loop. At some point it will LOCK on the server socket waiting for connection. Unless some client actually connects, it will keep on listening indefinatelly whithought ever bothering to check for the flag again (no matter how many times you set the damn thing to false).
    My question is this: Is there any real, non-theoretical, applied way to stop thread in java safely?
    Thank you in advance,
    Lefty

    This was one solution from the socket programming forum, have you tried this??
    public Thread MyThread extends Thread{
         boolean active = true;          
         public void run(){
              ss.setSoTimeout(90);               
              while (active){                   
                   try{                       
                        serverSocket = ss.accept();
                   catch (SocketTimeoutException ste){
                   // do nothing                   
         // interrupt thread           
         public void deactivate(){               
              active = false;
              // you gotta sleep for a time longer than the               
              // accept() timeout to make sure that timeout is finished.               
              try{
                   sleep(91);               
              }catch (InterruptedException ie){            
              interrupt();
    }

Maybe you are looking for

  • SATA controller drivers

    i have a t60 that i need to reinstall windows on.  this is not possible without the controller drivers. after tech support graciously hung up on me when they told me they didnt know what they were and didnt have them, i am left with no idea of where

  • Migrating a New Subscription in the Business Event

    We have created a new subscription for an existing business event. We need to migrate the subscription to the test and other instances. Download Subscription :-_ *$AFJVAPRG oracle.apps.fnd.wf.WFXLoad -d <apps> <apps_pwd> <machine_name:port_no:SID> th

  • Easy way to migrate users from one machine to another?

    I have an iMac lab where students have their own local accounts. The machines are bound to W2k Server with AD. New school year, new seating charts, some users must move. Is there an easy way to migrate a user and all their stuff from one machine to a

  • Small problem in randam access

    how to read from file and write to another by using randam access in java. thanks......

  • FM for converting unit form one uom to another

    hi, can any one provide me fm ehich can be used to convert volumn and weight of delivery from one unit of measutre to another? i tried with UNIT_CONVERSION_SIMPLE but it gives error saying Exception       INPUT_INVALID Message ID:          BM Message