Project 'NULL'

Buenas tardes
Realize una consulta en el generador de querys de SAP y encontre algo extraño
SELECT COUNT(Project) FROM POR1 WHERE DocEntry = 'X'
nosotros no usamos proyectos, por lo tanto el campo project queda NULL, pero al hacer la consulta me muestra igual la cantidad contada segun las lineas del documento.
Ahora bien, si yo genero una OC pasando por encima del campo project y colocando el Total ML, despues ejecuto la consulta no me cuenta nada como deberia ser, pero si me lo salto directamente a total ML sin pasar por el campo project, al ejecutar la consulta me cuenta el campo siendo que esta NULL
La version de SAP es 2007A SP 0 PL 49, aunque igual probre en uno con SP 01 PL 05 y sucede lo mismo
Alguien tiene idea de porque pasa esto?
Saludos
Atte.
FLR

Rulius
Como dices, bueno en mi caso no me afecta en nada en las filiales, pero si en la empresa mas grande donde habia estaba agregando un SP para los proyectos de linea, al no ejecutarse me encontre con el tema del campo, y cuando lo cambiaba por otro si me lo tomaba. Como dices debe ser por el tipo de datos que queda guardado en ese campo a diferencia de los demas.
Bueno, ahora probare de otra forma el SP
Saludos y gracias
Atte.
FLR

Similar Messages

  • Transforming to a user defined projection produces incorrect results

    Dear all
    I have set up a user defined projection in Oracle for an obsolete Ordnance Survey projection based on the Cassini-Soldner projection. I've got the projection itself to work but when I went to do a transformation from British National Grid (SRID 81989) to my projection, it failed to transform correctly.
    I have since realised I needed a transformation entry in the SDO_COORD_OPS table. However despite adding in an entry, which I've copied below, I cannot get the transformation to work correctly. Have I made a mistake iwth one of my entries or is there an entry I need to create else where in order for this to work. Also I am not certain what the difference is between CONVERSION and TRANSFORMATION. I would be grateful of any comments or help.
    INSERT INTO SDO_COORD_OPS (
    coord_op_id,
    coord_op_name,
    coord_op_type,
    source_srid,
    target_srid,
    coord_tfm_version,
    coord_op_variant,
    coord_op_method_id,
    uom_id_source_offsets,
    uom_id_target_offsets,
    information_source,
    data_source,
    show_operation,
    is_legacy,
    legacy_code,
    reverse_op,
    is_implemented_forward,
    is_implemented_reverse)
    VALUES (
    819899616,
    'British National Grid SRID 81989 to Cassini-Soldner vers D',
    'TRANSFORMAION',
    81989, -- this is the British National Grid projection
    96163497, -- this is the obsolete projection
    NULL,
    1,
    9633,  -- this refers to Ordnance Survey National Transformation in SDO_COORD_OP_METHODS
    NULL,
    NULL,
    'Brian Adams and Ordnance Survey',
    'Brian Adams and Ordnance Survey',
    1,
    'FALSE',
    NULL,
    1,
    0,
    0);I also have a conversion entry for the obsolete projection. This is as follows:
    INSERT INTO SDO_COORD_OPS (
    coord_op_id,
    coord_op_name,
    coord_op_type,
    source_srid,
    target_srid,
    coord_tfm_version,
    coord_op_variant,
    coord_op_method_id,
    uom_id_source_offsets,
    uom_id_target_offsets,
    information_source,
    data_source,
    show_operation,
    is_legacy,
    legacy_code,
    reverse_op,
    is_implemented_forward,
    is_implemented_reverse)
    VALUES (
    (1234567,
    'Cassini-Soldner vers D',
    'CONVERSION',
    NULL,
    NULL,
    NULL,
    NULL,
    9806, -- this refers to Cassini-Solder in SDO_COORD_OP_METHODS
    NULL,
    NULL,
    'Brian Adams',
    'Brian Adams and Ordnance Survey',
    1,
    'FALSE',
    NULL,
    1,
    1,
    1);and I will be making use of the following two entries, although like above this may be wrong.
    INSERT INTO SDO_COORD_OPS (
    coord_op_id,
    coord_op_name,
    coord_op_type,
    source_srid,
    target_srid,
    coord_tfm_version,
    coord_op_variant,
    coord_op_method_id,
    uom_id_source_offsets,
    uom_id_target_offsets,
    information_source,
    data_source,
    show_operation,
    is_legacy,
    legacy_code,
    reverse_op,
    is_implemented_forward,
    is_implemented_reverse)
    VALUES (
    961681989,
    'Cassini-Soldner vers D to British National Grid SRID 81989',
    'TRANSFORMAION',
    96163497, -- this is the obsolete projection
    81989,  -- this is the British National Grid projection
    NULL,
    1,
    9806, -- this refers to Cassini-Solder in SDO_COORD_OP_METHODS
    NULL,
    NULL,
    'Brian Adams',
    'Brian Adams and Ordnance Survey',
    1,
    'FALSE',
    NULL,
    1,
    0,
    0);
    INSERT INTO SDO_COORD_OPS (
    coord_op_id,
    coord_op_name,
    coord_op_type,
    source_srid,
    target_srid,
    coord_tfm_version,
    coord_op_variant,
    coord_op_method_id,
    uom_id_source_offsets,
    uom_id_target_offsets,
    information_source,
    data_source,
    show_operation,
    is_legacy,
    legacy_code,
    reverse_op,
    is_implemented_forward,
    is_implemented_reverse)
    VALUES (
    961627700,
    'Cassini-Soldner vers D to British National Grid SRID 27700',
    'TRANSFORMAION',
    96163497, -- this is the obsolete projection
    27700, -- this is the OSGB 1936 / British National Grid projection
    NULL,
    1,
    9806,  -- this refers to Cassini-Solder in SDO_COORD_OP_METHODS
    NULL,
    NULL,
    'Brian Adams',
    'Brian Adams and Ordnance Survey',
    1,
    'FALSE',
    NULL,
    1,
    0,
    0);Kind regards
    Tim

    Hi Mike
    Thank you so much for your help. I see where I went wrong. I thought the unit of measurement referred to the unit used to measure the distance when working with the projection. As all measuring is done in metres, I thought every uom_id value entered had to be set to metres. Where as in fact the uom_id actually refers to the unit of the figure being entered in that particular insert statement and not the unit eventually used to measure distance. I thought the parameter_id value told Oracle that it was in degrees, not the uom_id, since parameter_id refers to either the longitude of origin or latitude of origin, depending on which statement was being entered.
    I am coming at my work from the point of view of being a cartography and GIS specialist who is learning how to use Oracle, rather than an Oracle specialist who is learning about cartography and GIS. I found chapter 6 rather confusing whilst I was trying to understand how I insert a projection into Oracle, and in my confusion and attempts to understand what I needed to do, I made the above mistake.
    It does state on page 6-11 of the spatial manual, for UOM_ID, "ID number of the unit of measure associated with the operation." However as I'd never set up a projection in Oracle before, I really needed more a detailed explanations as to what needs to be done and more importantly, why it needs to be done. The introduction for the table states "The SDO_COORD_OP_PARAM_VALS table contains information about parameter values for each coordinate system transformation method." However that doesn't really explain in enough detail what it means in terms of what you need to enter and why it needs to be entered.
    There is one example of inserting a projection towards the end of the chapter but it does not explain the different stages of entry and what they mean in enough detail. I had to keep referring back to the tables, in order to try and understand what is going on and that got very confusing at times. I have both the original and revised editions of Pro Oracle Spatial but they just refer me to the spatial manual for the insertion of a user defined projection. It would be really good if someone wrote a book or booklet explaining in more detail the spatial projection creation side of things in Oracle.
    I do not have privileges to insert the statements myself but when the person with the correct privileges returns from their Easter break I will get the changes made. Regarding the Airy 1830 projection, I am given two results in both cases when I run the below statements. I know that the original map uses the 1830 Airy and not the 1847 modified, which is why I've used the former in both cases. If there is another Airy that I have missed then I would be grateful if you could tell me which values I need and I will get those entries amended too:
    select * from SDO_DATUMS
    where datum_name like '%Airy%'
    DATUM_ID               DATUM_NAME                                                                       DATUM_TYPE               ELLIPSOID_ID           PRIME_MERIDIAN_ID      INFORMATION_SOURCE                                                                                                                                                                                                                                             DATA_SOURCE                              SHIFT_X                SHIFT_Y                SHIFT_Z                ROTATE_X               ROTATE_Y               ROTATE_Z               SCALE_ADJUST           IS_LEGACY LEGACY_CODE           
    6001                   Not specified (based on Airy 1830 ellipsoid)                                     GEODETIC                 7001                   8901                   EPSG                                                                                                                                                                                                                                                           EPSG                                                                                                                                                                                                      FALSE                           
    6002                   Not specified (based on Airy Modified 1849 ellipsoid)                            GEODETIC                 7002                   8901                   EPSG                                                                                                                                                                                                                                                           EPSG                                                                                                                                                                                                      FALSE                           
    2 rows selected
    select * from SDO_CRS_GEOGRAPHIC2D
    where COORD_REF_SYS_NAME like '%Airy%';
    SRID                   COORD_REF_SYS_NAME                                                               COORD_SYS_ID           DATUM_ID               INFORMATION_SOURCE                                                                                                                                                                                                                                             DATA_SOURCE                             
    4001                   Unknown datum based upon the Airy 1830 ellipsoid                                 6422                   6001                   EPSG                                                                                                                                                                                                                                                           EPSG                                    
    4002                   Unknown datum based upon the Airy Modified 1849 ellipsoid                        6422                   6002                   EPSG                                                                                                                                                                                                                                                           EPSG                                    
    2 rows selectedAs I hadn't looked through chapter 6 of spatial manual since last August, in relation to my original insert statement for sdo_coord_ref_system table, it took me sometime to figure out where to locate the other tables containing the related entries I required. Which backs up my opinion for the need of even more detailed information on the different tables, including how they link and why they link.
    Kind regards and once again thank you for your help
    Tim

  • CSOM 2013 set project owner

    Hi.
    I'm writing a script to create projects in a Project Server 2013 Web App.
    But I didn't find how to set the owner of y projects. I would tlike to have a default user. Instead at the creation the owner is always my current account.
    My code :
    /// <summary>
    /// Create a project
    /// </summary>
    private PublishedProject CreateProject(ProjectsLoopEventArgs args)
    // ProjectsLoopEventArgs contain data I need to create my project
    PublishedProject project = null;
    // Define required informations
    ProjectCreationInformation projInfo = new ProjectCreationInformation();
    projInfo.Id = Guid.NewGuid();
    projInfo.Name = args.Title;
    projInfo.Description = args.Description;
    projInfo.Start = args.ProjectStartDate.Date;
    projInfo.EnterpriseProjectTypeId = this.ProjectType;
    // Create the project
    project = this.Context.Projects.Add(projInfo);
    return project;
    /// <summary>
    /// Add a project to the project collection
    /// </summary>
    private void AddProject(ProjectsLoopEventArgs args)
    try
    if (!ExistsProject(args))
    // create project
    PublishedProject project = CreateProject(args);
    // update project owner
    project.Owner = this.DefaultResource.User; //doesnt work
    // update custom fields
    UpdateProjectCustomFields(project, args); //set my custom fields values, it works
    // add it to the project collection
    QueueJob qJob = this.Context.Projects.Update();
    JobState jobState = this.Context.WaitForQueue(qJob, this.Config.Timeout);
    // if job succeed
    if (jobState == JobState.Success)
    // raise event
    OnProjectAddedEvent(new ProjectAddedEventArgs(args));
    else
    // raise event
    OnQueueErrorEvent(new QueueErrorEventArgs(args, jobState, this.Config.Timeout));
    else
    // raise event
    OnProjectExistsEvent(new ProjectExistsEventArgs(args));
    catch (Exception e)
    OnScriptErrorEvent(new ScriptErrorEventArgs(args, e));
    Have I miss something ?

    Hi.
    Anyone can help to update the project owner ?

  • Sort table columns in a table and context created dinamically

    Hello all,
    I have implemented the table sorting several times in another developments, but now I'm facing a problem.
    I have created the table and context node that I need to sort dinamically (before somebody ask me why, I would say that it's the only way to do that for my current project, there was no possibility of doing that in dessign time). I have implemented the table sorting more or less the same way I would do with a table created in dessing time, but when I run my WD the sorting of columns doesn't work.
    In the wdDoModifyView, I have put the following code:
    if(firstTime){
    IWDAction ordenacion     = wdThis.wdCreateAction(IPrivateResultDispGlobalView.WDActionEventHandler.ORDENACION,  null);
    IWDParameters param = ordenacion.getActionParameters();
    param.addParameter("nombreNodo",nombreNodo);
    and in the code of the action
        //@@begin onActionOrdenacion(ServerEvent)
         System.err.println("**** NOMBRE NODO **** "+nombreNodo);
         wdContext.currentContextElement().getTableSorter().sort(wdEvent, wdContext.getChildNode(nombreNodo, IWDNode.LEAD_SELECTION));
        //@@end
    The name of the node ("nombreNodo) it's only correct the first time I click on a column.
    Has anybody implemented the table sorting in a dinamically created table and context node? And how do you do to make it works.
    Thank you very much

    Here is the code
    //Preparamos Navegaciones
    IWDAction abrirProyecto = wdThis.wdCreateAction(IPrivateResultDispGlobalView.WDActionEventHandler.ABRIR_PROYECTO, null);
    IWDAction abrirDisp     = wdThis.wdCreateAction(IPrivateResultDispGlobalView.WDActionEventHandler.ABRIR_DISPONIBLE,  null);
    //IWDAction ordenacion     = wdThis.wdCreateAction(IPrivateResultDispGlobalView.WDActionEventHandler.ORDENACION,  null);
    IWDAction ordenacion=wdThis.wdGetOrdenacionAction();
    IWDParameters param = ordenacion.getActionParameters();
    param.addParameter("nombreNodo",nombreNodo);
    IWDTable table = wdThis.wdGetInformesController().crearTabla(view, nombreNodo, movimientosInfo,new String[]{"Codi Projecte",null,"Nom Projecte", "Import Projecte", "Client", "Increment Disponible futur per facturació no emesa i / o anualitats pendents","Increment Disponible futur per ingressos pendents de cobrar", "Disponible"},new String[]{"10px", null,"10px", "10px","10px","10px","10px","10px"},new IWDAction[]{abrirProyecto,null, null, null, null,null,null,abrirDisp}, -1);
    //ordenar tabla
    wdContext.currentContextElement().setTableSorter(new TableSorter(table, ordenacion,null));
    containerTablasProyecto.addChild(table);
    Edited by: Mireia Romo on May 28, 2009 12:27 PM

  • Running FlexUnit tests from command line

    Sorry if that has been posted before: I searched best I could and nothing came up.
    I am interested in building and running my unit tests from the command line so we can add it to a nightly build process.
    I am *very* new to all this: basically I picked up Adobe Flash Builder 4 a month ago and I have done *everything* inside that IDE: writing code, building, testing, running.
    I looked into at least how to build something from the command line, I found this:
    http://help.adobe.com/en_US/flashbuilder/using/WSbde04e3d3e6474c4-59108b2e1215eb9d5e4-8000 .html
    Can't get past this error:
    Buildfile: /Users/dbanks/build_test.xml
    BUILD FAILED
    Target "FlexUnitApplication" does not exist in the project "null".
    Total time: 0 seconds
    Adobe Flash Builder 4:
    An error has occurred. See the log file
    /Users/dbanks/Documents/Adobe Flash Builder 4/.metadata/.log.
    Plus, even if I got this going, I am just building the swf.  I also want to run it and capture the output in some meaningful way that can be read/evaluated/acted on.
    FWIW, the script/xml I am using to try to build:
    build_test.xml:
    <?xml version="1.0"?>
    <project default="main">
        <target name="main">
            <fb.exportReleaseBuild project="NightclubMogul" />
        </target>
    </project>
    execute_build_test.sh:
    WORKSPACE="$HOME/Documents/AdobeFlashBuilder4"
    # works with either FlashBuilder.app or Eclipse.app
    "/Applications/AdobeFlashBuilder4" \
        --launcher.suppressErrors   \
        -noSplash   \
        -application org.eclipse.ant.core.antRunner   \
        -data "$WORKSPACE"    \
        -file "/Users/dbanks/build_test.xml" FlexUnitApplication
    I am not clear what in here is actually supposed to point to where my project lives: it's off in some directory somewhere.  I see that I am pointing to a workspace (Documents/AdobeFlashBuilder4) but when I poke around in there I don't see anything connecting back to the directories where the code lives.
    Any help would be great: getting the tests to build from command line, then getting them to run.

    C:\>sqlplus @myscript
    That would be the easiest variation
    C:\>sqlplus user/passwd@tns_alias @myscript
    would be an often used variation
    And then there is of course the version with parameter passing:
    C:\>sqlplus user/passwd@tns_alias @myscript param1 ... paramx
    Dunno about MSBuild

  • Android: How to upload a file to OneDrive?

    Iam trying to upload a file using the OneDrive Saver sample app. Instead of creating a text file, I would like to select a file from the gallery and then upload it to OneDrive. I have edited the sample app but the file cannot be uploaded. I don't have
    any errors. 
    Sample app available on GitHub (https://github.com/OneDrive/onedrive-picker-android/tree/master/SaverSample).
        package com.example.onedrivesdk.saversample;
        import java.io.*;
        import android.accounts.AccountManager;
        import android.app.Activity;
        import android.content.ContentResolver;
        import android.content.Intent;
        import android.database.Cursor;
        import android.graphics.Bitmap;
        import android.graphics.BitmapFactory;
        import android.net.Uri;
        import android.os.*;
        import android.provider.MediaStore;
        import android.view.View;
        import android.view.View.OnClickListener;
        import android.widget.*;
        import com.microsoft.onedrivesdk.saver.*;
        public class SaverMain extends Activity {
            private static final int DEFAULT_FILE_SIZE_KB = 100;
            static final int RESULT_STORE_FILE = 4;
            private static Uri mFileUri;
            private static final String ONEDRIVE_APP_ID = "4813EF88";
            private final OnClickListener mStartPickingListener = new OnClickListener() {
                @Override
                public void onClick(final View v) {
                final Intent galleryIntent = new Intent(Intent.ACTION_PICK);
                    galleryIntent.setType("*/*");
                    startActivityForResult(galleryIntent, RESULT_STORE_FILE);
            private ISaver mSaver;
            @Override
            protected void onCreate(final Bundle savedInstanceState) {
                super.onCreate(savedInstanceState);
                setContentView(R.layout.activity_saver_main);
                // Create the picker instance
                mSaver = Saver.createSaver(ONEDRIVE_APP_ID);
                // Add the start saving listener
                findViewById(R.id.startSaverButton).setOnClickListener(mStartPickingListener);
            @Override
            protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
            try {
                    mSaver.handleSave(requestCode, resultCode, data);
                } catch (final SaverException e) {
            switch (requestCode) 
        case RESULT_STORE_FILE:
        mFileUri = data.getData();
        saveFileToDrive();
        break;
            private void saveFileToDrive() 
            Thread t = new Thread(new Runnable() 
            @Override
            public void run() 
        try 
        // Create URI from real path
        String path;
        path = getPathFromUri(mFileUri);
        mFileUri = Uri.fromFile(new java.io.File(path));
        ContentResolver cR = SaverMain.this.getContentResolver();
        // File's binary content
        java.io.File fileContent = new java.io.File(mFileUri.getPath());
        View v = null;
        final Activity activity = (Activity) v.getContext();
        mSaver.startSaving(activity, path, Uri.parse(mFileUri.toString()));
        } catch (Exception e) {
            t.start();
            public String getPathFromUri(Uri uri) 
                  String[] projection = { MediaStore.Images.Media.DATA };
                  Cursor cursor = getContentResolver().query(uri, projection, null, null, null);
                  int column_index = cursor
                          .getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
                  cursor.moveToFirst();
                  return cursor.getString(column_index);

    You're going to need to give way more detail about the situation before we can help.

  • Profile customized attribute is not working?

    Hi,
    I downloaded ‘WCSpacesExtensions’ project from Oracle because I want to add some customize attributes to Profile. I added ‘project’ to ExtendedProfileAttributes.java, and created getter and setter methods. In a jsff, this is my EL #{wcProfileCustomAttribute['securityContext.userName'].project}. The setProject() sets up the attribute, but when getProject() is invoked, ‘project’ is returned as NULL.
    Every time the jsff page references the attributes via EL, it creates a new instance ExtendedProfileAttributes obj. because you can see it calls the constructor over and over. It saves value of ‘sip’ (=> setSip():12345), but when trying to read its value, it's NULL (=> getSip():null). So, I can't read and save the attribute per user.
    Any feedback is greatly appreciated.
    .jsff page
    <mds:insert after="oliplam3" parent="olipfl1"
    xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
    <af:panelLabelAndMessage xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
    label="*Sip" id="splam2">
    <af:inputText xmlns:af="http://xmlns.oracle.com/adf/faces/rich" id="sit1"
    value="#{wcProfileCustomAttribute[(pageFlowScope.userId == null ? securityContext.userName : pageFlowScope.userId)].sip}"/>
    </af:panelLabelAndMessage>
    </mds:insert>
    <mds:insert after="splam2" xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
    <af:panelLabelAndMessage xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
    label="*Proj" id="splam3">
    <af:inputText xmlns:af="http://xmlns.oracle.com/adf/faces/rich" id="sit2"
    value="#{wcProfileCustomAttribute[(pageFlowScope.userId == null ? securityContext.userName : pageFlowScope.userId)].project}"/>
    </af:panelLabelAndMessage>
    </mds:insert>
    ExtendedProfileAttributes.java
    package custom.webcenter.spaces;
    import oracle.adf.share.logging.ADFLogger;
    * This is a sample class for profile extension
    * Add getter (and setter if you need to save)
    * for any new custom attribute.
    * New attriutes defined here can be acessed
    * via EL like
    * #{wcProfileCustomAttribute['smith'].sip}
    * in the jspx/jsff.
    public class ExtendedProfileAttributes
    private String sip;
    private String project;
    public ExtendedProfileAttributes(String profileID)
    // Query from custom attribute source and cache them
    //project = profileID + "'s Project";
    //mSIP = profileID + "'s SIP address!!!***";
    //mStreetAddress = profileID + "'s street address";
    System.out.println("ExtendedProfileAttributes(). user:" + profileID);
    System.out.println("ExtendedProfileAttributes(). sip:" + sip + " project:" + project);
    public void setSip(String s) {
    this.sip = s;
    System.out.println("=> setSip():" + this.sip);
    public String getSip() {
    System.out.println("=> getSip():" + this.sip);
    return this.sip;
    private static String CLASS_NAME = ExtendedProfileAttributes.class.getName();
    public void setProject(String project) {
    this.project = project;
    System.out.println("=> setProject():" + this.project);
    public String getProject() {
    System.out.println("=> getProject():" + this.project);
    return project;
    DEBUGGING:
    ===========
    ExtendedProfileAttributes(). user:securityContext.userName
    ExtendedProfileAttributes(). sip:null project:null
    => setSip():12345
    ExtendedProfileAttributes(). user:weblogic
    ExtendedProfileAttributes(). sip:null project:null
    => setProject():333
    <Feb 24, 2012 11:24:57 AM EST> <Warning> <oracle.adfinternal.view.faces.renderkit.rich.RegionRenderer> <ADF_FACES-60099> <The region component with id: T:wcCmdLinkGSSwit:spaceSwitcherComp:crtGS has detected a page fragment with multiple root components. Fragments with more than one root component may not display correctly in a region and may have a negative impact on performance. It is recommended that you restructure the page fragment to have a single root component.>
    <Feb 24, 2012 11:24:57 AM EST> <Warning> <oracle.adfinternal.view.faces.renderkit.rich.RegionRenderer> <ADF_FACES-60099> <The region component with id: T:spcNavPanel:dc_r3 has detected a page fragment with multiple root components. Fragments with more than one root component may not display correctly in a region and may have a negative impact on performance. It is recommended that you restructure the page fragment to have a single root component.>
    ExtendedProfileAttributes(). user:weblogic
    ExtendedProfileAttributes(). sip:null project:null
    ExtendedProfileAttributes(). user:weblogic
    ExtendedProfileAttributes(). sip:null project:null
    ExtendedProfileAttributes(). user:weblogic
    ExtendedProfileAttributes(). sip:null project:null
    => getSip():null
    Thanks a lot.

    Hi,
    if this is a WebCenter specific issue, they do have their own forum on OTN: WebCenter Portal
    Frank

  • When to use doGet(...) and when to use doPost(..)

    Hi,
    here is what i would like to do:
    I have a html file that will take user input and pass these inputs to a servlet as parameters. the servlet then uses these input parameters to query for data in a database and then write this results back to the browser. Here is my problem:
    If I use doGet(...) and hardcode the input parameters instead of taking them from the html file, I then can compile and run it from Jdev IDE. And if I use doPost(..) instead, I can only compile the servlet, but when run, I got the error message :
    "The page cannot be displayed
    The page you are looking for cannot be displayed because the address is incorrect."
    To my understanding, please correct me if I am wrong,we use doPost() to accept pararmeters from a html. Please help me. thank you very much.
    Tran T.
    codes are as below:
    <HTML>
    <HEAD><TITLE>Session Payment Status</TITLE></HEAD>
    <BODY>
    <FORM ACTION="http://localhost:8080/servlet/SessionPaymentStatus" TARGET="FRA2" METHOD="POST">
    <CENTER><H1><FONT COLOR="GREEN" SIZE="5"> Session Payment Status</FONT></H1></CENTER>
    </HTML>
    And my servlet is:
    package paymentstatus;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import gmstocms.*;
    import java.util.*;
    import com.gaexpress.javaadapter.*;
    public class PaymentStatus extends HttpServlet {
    //CMS Related
    private String xmlRecord = null;
    private String storedProc = null;
    private String ID = null;
    private CmsXmlParser parsedRecord = null;
    private Vector vecData = null;
    //Record Header
    String RecordID = null;
    public void init(){
    this.storedProc = "OLEDB$GETSESS";
    this.ID = "CE97607";
    public String getCMSRecord(){
    //xmlRecord = new String (CMSTest.executeSP("OLEDB$GETSESS","CE97465"));
    return new String (CMSTest.executeSP(storedProc,ID));
    public CmsXmlParser getParsedRecord(){
    if(parsedRecord == null){
    parsedRecord = new CmsXmlParser(getCMSRecord());
    return parsedRecord;
    public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException{
    res.setContentType("text/html");
    //res.setHeader("Welcome to Directional Project", null);
    PrintWriter out = res.getWriter();
    getParameters(req);
    out.println("<LEFT><H2><FONT COLOR=GREEN SIZE=3>" + getParsedRecord().getCMSRecordHeader() + "</FONT></H2></LEFT>");
    out.println("<HTML>");
    out.println("<HEAD>");
    out.println("<TITLE> Bidirectional Project </TITLE>");
    out.println("</HEAD>");
    out.println("<LEFT><H2><FONT COLOR=GREEN SIZE=3>" + getParsedRecord().getCMSRecordHeader() + "</FONT></H2></LEFT>");
    out.println("</HTML>");
    out.close();
    //get the parameters to for the email to be sent to the given address
    private void getParameters(HttpServletRequest req) throws ServletException, IOException {
    this.storedProc = req.getParameter("optProName");
    this.ID = req.getParameter("optCustID");
    null

    U can use doPost() simply call the doGet() in the doPost() as follow...
    Let me know if u still have problem...
    public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException{
    doGet(req, res);
    null

  • How to call imported ant target/task in Java

    Hi,
    Can anybody advice me how to call an ant target/task, which is
    "<import/>"ed from another build file, from within Java code?
    Here's my Java code:
    import org.apache.tools.ant.*;
    import java.io.*;
    import java.util.*;
    public class MyTest
    private Project project;
    public void init(String buildFile, String baseDir) throws
    Exception
    project = new Project();
    try { project.init(); }
    catch (BuildException e)
    { throw new Exception("The default task list could not be
    loaded."
    // Set the base directory. If none is given, "." is used.
    if (_baseDir == null) _baseDir=new String(".");
    try { project.setBasedir(_baseDir); }
    catch (BuildException e)
    { throw new Exception("The given basedir doesn't exist, or
    isn't a directory."); }
    if (_buildFile == null) _buildFile=new String("a.xml");
    try { ProjectHelper.getProjectHelper().parse(project, new
    File(_buildFile)); }
    catch (BuildException e)
    { throw new Exception("Configuration file "+_buildFile+" is
    invalid, or cannot be read."); }
    public void runTarget(String _target) throws Exception
    // Test if the project exists
    if (project == null) throw new Exception("No target can be
    launched because the project has not been initialized. Please call the
    'init' method first !");
    // If no target is specified, run the default one.
    if (_target == null) _target = project.getDefaultTarget();
    // Run the target
    try { project.executeTarget(_target); }
    catch (Exception e)
    { throw new Exception(e.getMessage()); }
    public static void main(String args[])
    try{
    MyTest mytest=new MyTest();
    mytest.init("c.xml",".");
    mytest.runTarget(null);
    }catch(Exception e)
    e.printStackTrace();
    Here are my build files: (they look almost the same. But it's only to see if <import> works.)
    1.c.xml:
    <project basedir="." default="runtests" name="TestC">
    <import file="a.xml"/>
    </project>
    2. a.xml:
    <project basedir="." default="runtests" name="TestA">
    <target name="runtests" depends="">
    <mkdir dir="ttt"/>
    </target>
    </project>
    If I directly set build file "a.xml" in MyTest.java, everthing works
    well. However, if set "c.xml" then do task "<mkdir dir="ttt"/>" defined
    in "a.xml" which was imported by "c.xml", when running, I got an
    exception. Looks like it can't parse my c.xml which include "import".
    BTW, I'm using ant 1.6.2, and running "ant -f c.xml" was ok.
    Did I miss any classpath or something? Any idea?
    Thanks,
    Amy

    I have a standard Ant build script for signing a jar file. I import it into my master Ant build files with
    <import file="Sign.xml"/>
    and then in my master Ant script I setup the name of the jar file e.g.
    <property name="jar-file" value="${fun}/FunApplet.jar"/>
    and then invoke a target
    <target name="sign-jar" depends="jar, sign">
    </target>
    Since this target (sign-jar) depends on target 'jar' and target 'sign' it executes the 'jar' target and then the 'sign' target that is contained in Sign.xml.

  • Result Set Causing out of memory issue

    Hi,
    I am having trouble to fix the memory issue caused by result set.I am using jdk 1.5 and sql server 2000 as the backend. When I try to execute a statement the result set returns minimum of 400,000 records and I have to go through each and every record one by one and put some business logic and update the rows and after updating around 1000 rows my application is going out of memory. Here is the original code:
    Statement stmt = con.createStatement();
    ResultSet   rs = st.executeQuery("Select * from  database tablename where field= 'done'");
                while(rs!=null && rs.next()){
                System.out.println("doing some logic here");
    rs.close();
    st.close();
    I am planning to fix the code in this way:
    Statement stmt = con.createStatement(ResultSet.TYPE_FORWARD_ONLY,
                          ResultSet.CONCUR_UPDATABLE);
    stmt.setFetchSize(50);
    ResultSet   rs = st.executeQuery("Select * from  database tablename where field= 'done'");
                while(rs!=null && rs.next()){
                System.out.println("doing some logic here");
    rs.close();
    st.close();But one of my colleague told me that setFetchSize() method does not work with sql server 2000 driver.
    So Please suggest me how to fix this issue. I am sure there will be a way to do this but I am just not aware of it.
    Thanks for your help in advance.

    Here is the full-fledged code.There is Team Connect and Top Link Api being used. The code is already been developed and its working for 2-3 hours and then it fails.I just have to fix the memory issue. Please suggest me something:
    Statement stmt = con.createStatement();
    ResultSet   rs = st.executeQuery("Select * from  database tablename where field= 'done'");
                while(rs!=null && rs.next()){
                 /where vo is the value object obtained from the rs row by row     
                if (updateInfo(vo, user)){
                               logger.info("updated : "+ rs.getString("number_string"));
                               projCount++;
    rs.close();
    st.close();
    private boolean updateInfo(CostCenter vo, YNUser tcUser) {
              boolean updated;
              UnitOfWork unitOfWork;
              updated = false;
              unitOfWork = null;
              List projList_m = null;
              try {
                   logger.info("Before vo.getId() HERE i AM" + vo.getId());
                   unitOfWork = FNClientSessionManager.acquireUnitOfWork(tcUser);
                   ExpressionBuilder expressionBuilder = new ExpressionBuilder();
                   Expression ex1 = expressionBuilder.get("application")
                             .get("projObjectDefinition").get("uniqueCode").equal(
                                       "TABLE-NAME");
                   Expression ex2 = expressionBuilder.get("primaryKey")
                             .equal(vo.getPrimaryKey());// primaryKey;
                   Expression finalExpression = ex1.and(ex2);
                   ReadAllQuery projectQuery = new ReadAllQuery(FQUtility
                             .classForEntityName("EntryTable"), finalExpression);
                   List projList = (List) unitOfWork.executeQuery(projectQuery);
                   logger.info("list value1" + projList.size());
                   TNProject project_hist = (TNProject) projList.get(0); // primary key
                   // value
                   logger.info("vo.getId1()" + vo.getId());
                   BNDetail detail = project_hist.getDetailForKey("TABLE-NAME");
                   project_hist.setNumberString(project_hist.getNumberString());
                   project_hist.setName(project_hist.getName());
                   String strNumberString = project_hist.getNumberString();
                   TNHistory history = FNHistFactory.createHistory(project_hist,
                             "Proj Update");
                   history.addDetail("HIST_TABLE-NAME");
                   history.setDefaultCategory("HIST_TABLE-NAME");
                   BNDetail histDetail = history.getDetailForKey("HIST_TABLE-NAME");
                   String strName = project_hist.getName();
                   unitOfWork.registerNewObject(histDetail);
                   setDetailCCGSHistFields(strNumberString, strName, detail,
                             histDetail);
                   logger.info("No Issue");
                   TNProject project = (TNProject) projList.get(0);
                   project.setName(vo.getName());
                   logger.info("vo.getName()" + vo.getName());
                   project.setNumberString(vo.getId());
                   BNDetail detailObj = project.getDetailForKey("TABLE-NAME"); // required
                   setDetailFields(vo, detailObj);//this method gets the value from vo and sets in the detail_up object
                   FNClientSessionManager.commit(unitOfWork);
                   updated = true;
                   unitOfWork.release();
              } catch (Exception e) {
                   logger.warn("update: caused exception, "
                             + e.getMessage());
                   unitOfWork.release();
              return updated;
         }Now I have tried to change little bit in the code. And I added the following lines:
                        updated = true;
                     FNClientSessionManager.release(unitOfWork);
                     project_hist=null;
                     detail=null;
                     history=null;
                     project=null;
                     detailObj=null;
                        unitOfWork.release();
                        unitOfWork=null;
                     expressionBuilder=null;
                     ex1=null;
                     ex2=null;
                     finalExpression=null;
    and also I added the code to request the Garbage collector after every 5th update:
    if (updateInfo(vo, user)){
                               logger.info("project update : "+ rs.getString("number_string"));
                               projCount++;
                               //call garbage collector every 5th record update
                               if(projCount%5==0){
                                    System.gc();
                                    logger.debug("Called Garbage Collectory on "+projCount+"th update");
                          }But now the code wont even update the single record. So please look into the code and suggest me something so that I can stop banging my head against the wall.

  • Code to run a query in SQL from Access with pass through query

    I have a query in SQL Server 2008:
     [Auto Null Up Date].sql. I want to run this query from Access 2007 using a Pass Through Query. What is the command/code to run this query from Access? I have used Pass Through Queries but never in this capacity so I am somewhat lost. I have
    already established the OBDC link and tested.

    Naomi,
    Here are a few lines of the SQLCMD code in the [Auto Null Update].sql query:
    USE [Archive Master]
    Go
    :r "\\10.200.1.60\c$\Users\bkreft\My Documents\SQL Server Management Studio\Projects\Null BackPress 2 update.sql"
    GO
    :r "\\10.200.1.60\c$\Users\bkreft\My Documents\SQL Server Management Studio\Projects\Null CHWR 3 update.sql"
    GO
    :r "\\10.200.1.60\c$\Users\bkreft\My Documents\SQL Server Management Studio\Projects\Null CHWR 4 update.sql"
    When this code is pasted into a Create Procedure, (the USE [Archive Master] is not used), the procedure will run, but once saved here is what is left of the procedure once I attempt to modify:
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    -- =============================================
    -- Author:                         
    <Author,,Name>
    -- Create date: <Create Date,,>
    -- Description:              
    <Description,,>
    -- =============================================
    Create PROCEDURE [dbo].[NullTest2]
    AS

  • Database Adapter Problem

    Hi, I have a BPEL process that whenever I try to edit any of the database adapters I get an "java.lang.nullpointerexception" error. The only place where I can think the problem could be is at the toplink mappings, as when I go there I get the error "There was a problem encountered loading the TopLink Mappings project: null". I have redone the process, and then it works, only to give the same error again later, without any changes begin made.
    Please Help

    I found the solotion!!
    Create the view with a sqript and from sqlplus and NOT from Toad.
    or
    Goto <Project Folder> -> <database> -> <apps> -> <xxxx.view> ,go to the end, and remove the NUL value.
    Thanks for the help any way!
    Rafikki

  • Reports sum don't sum as they should

    Hi,
    I created a report where it displays, in order: COST CENTER, PROJECT, EMPLOYEE, JAN, FEB... DEC
    Then I check on sum for JAN, FEB.... DEC under columns attributes.
    Then I have a break for the first and second columns (COST CENTER, PROJECT), so it will give me a sum for project total, and a sum for cost center total.
    The thing is that there is a case that the project is the same, but in different cost center, what the report is doing is that since the project is the same, even though the cost center is different, it's returning a sum for project total combining 2 different cost centers. This should not happen since cost center is highest in the hierarchy so even 2 different cost centers with the same projects, it should return a sum of the projects separtely, since although the same project, they belong to 2 different cost centers.
    How can I fix this?
    Thanks,

    I have no idea if this is "good" SQL or not, I played with it until it worked. :-)
    Going through the SQL a line at a time:
    select decode(grouping_id(cost_center)+grouping_id(project)+grouping_id(amount),3, 'Report Total:',2,'Cost Center '||cost_center||' Subtotal:',1,'Project '||project||' Subtotal:',0,null) tag,grouping_id(item) is set to 1 when that item level is being totaled, 0 otherwise. So this is basically a case statement. Column 1 is the 'Tag' field, which is just a label and not in the database.
    If the sum of the grouping_id values is 3, then select the text 'Report Total:' for column 1
    Else if the sum is 2, select 'Cost Center ' concatenated with the value of the current cost center, concatenated with 'Subtotal:' in for column 1
    Else if the sum is 1, you're subtotalling the project, so select 'Project' concatenated with the project value and 'Subtotal:' for the 'Tag' column.
    Otherwise, display null.
    This brings up a feature I'd like to see in ApEx: It would be nice to be able to display not only the column headers in the break row, but also the value/name of the item currently being totaled. Another nice feature would be if I could get around having to use this 'Tag' field and, instead, have column 1 span several TD cells so that I could get the label over next to the subtotal values instead of in column 1.
    On to line/column 2. Similar to before, this is a case statement, determining what goes in the cost_center field:
    decode(grouping_id(cost_center)+grouping_id(project)+grouping_id(amount),0,cost_center,null) cost_center, If the sum of all three grouping ids is 0 (not rolling up or subtotalling), show cost_center, otherwise show null.
    The next line, for project, works the same way.
    decode(grouping_id(cost_center)+grouping_id(project)+grouping_id(amount),0,project,null) project, If the sum of all three grouping ids is 0 (not rolling up or subtotalling), show project, otherwise, show null.
    The next field, Amount, is a little tricky:
    decode(sum(amount),amount,amount,sum(amount)) amount, Again, take it as a case statement (or if-then-elseif)...
    if the sum(amount) is the same as amount (displaying regular row), show the amount, otherwise, show the sum(amount).
    Why do this? Because I don't want two columns for amount and sum(amount). I want the sum to display in the Amount field on a report row. I suppose I could have summed up the grouping_id values as before, eh?
    In the report attributes, I suppress the display of the last field, sum(amount).
    sum(amount) The final bit defines the grouping sets:
    from breakreport group by grouping sets((cost_center, project, amount),(cost_center, project), (cost_center),());This says: Aggregate on amount, then project, then cost center, then give an overall total.
    Google for "grouping_id oracle" and you'll find a bunch of very nice links to Ask Tom and other places that discuss grouping.

  • New to J2EE; Best Practices

    Hi everyone, and thanks in advance for all of your help.
    I'm somewhat new to J2EE, at least in the sense of creating my own application. I work for a small software company in New England, and have to work on an enterprise application as part of my job; unfortunately, I don't get much exposure to the total of J2EE. Instead, most of my work is on small extensions, database scripts, or external projects that don't quite give me the exposure I'm looking for.
    As an exercise, I've decided to put together a sample J2EE application. I've spent time reading the (many) J2EE tutorials out there, but I'm having trouble putting it all together. This application works, but I know that I've used some bad patterns, and was hoping to get some feedback. My application consists of 4 Java classes and 8 JSPs, but none over 100 lines, and only 1 above 50.
    One final note before I start: yes, I know there are some frameworks out there that would help; I plan on migrating to Struts at some point. However, I wanted to make sure I understand the core J2EE structure before I delved into that.
    My application simply allows a user to add, edit, or delete entries in a database. The database consists of 1 table (Projects), with two fields: an id, and a name.
    The first page, Projects.jsp, lists the current projects in the database for the user:
    <%@ page contentType="text/html; charset=UTF-8" %>
    <%@ page pageEncoding="UTF-8" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <jsp:useBean id="projectsDAO"
                 class="com.emptoris.dataAccess.ProjectsDataAccessObject"
                 scope="application" />
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <title>Projects</title>
      </head>
      <body>
        <form name="projectsForm"
              action="<%= response.encodeURL("ProjectsController.jsp") %>"
              method="post">
          <c:if test="${projectsDAO.projects.numberOfProjects > 0}">
            <table>
              <tr>
                <th>Select</th>
                <th>ID</th>
                <th>Name</th>
              </tr>
              <c:forEach items="${projectsDAO.projects.projects}" var="project"
                         step="1">
                <tr>
                  <td>
                    <input type="radio" name="projectId" value="${project.id}" />
                  </td>
                  <td><c:out value="${project.id}" /></td>
                  <td><c:out value="${project.name}" /></td>
                </tr>
              </c:forEach>
            </table>
            <input type="submit" name="action" value="Edit Project" />
            <input type="submit" name="action" value="Delete Project" />
          </c:if>
          <input type="submit" name="action" value="Add New Project" />
        </form>
      </body>
    </html>The ProjectsDataAccessObject is a class that simply mirrors the table in the database. Adding, editing, or removing entries in this class will modify the database accordingly:
    package com.emptoris.dataAccess;
    import java.sql.*;
    import com.emptoris.model.*;
    public class ProjectsDataAccessObject {
        private Connection connection;
        private Statement statement;
        private Projects projects;
        public ProjectsDataAccessObject() throws ClassNotFoundException,
            SQLException {
            Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
            connection =
                DriverManager.getConnection(
                    "jdbc:microsoft:sqlserver://AFRASSO:1433", "sa", "password"
            statement = connection.createStatement();
            statement.execute("USE test");
        public Project getProject(int id) throws SQLException {
            Projects projects = getProjects();
            Project project = projects.getProject(id);
            return project;
        public Projects getProjects() throws SQLException {
            if (projects == null) {
                projects = new Projects();
                String query = "SELECT id, name FROM Projects";
                ResultSet resultSet = statement.executeQuery(query);
                Project project;
                while(resultSet.next()) {
                    project = new Project();
                    project.setId(resultSet.getInt(1));
                    project.setName(resultSet.getString(2));
                    projects.addProject(project);
            return projects;
        public void addNewProject(Project project) throws SQLException {
            String query =
                "INSERT INTO Projects (name) VALUES ('" + project.getName() + "')";
            statement.execute(query);
            query =
                "SELECT MAX(id) FROM Projects";
            ResultSet resultSet = statement.executeQuery(query);
            resultSet.next();
            project.setId(resultSet.getInt(1));
            projects.addProject((Project) project.clone());
        public void removeExistingProject(int id) throws SQLException {
            String query =
                "DELETE FROM Projects WHERE id = " + id;
            statement.execute(query);
            projects.removeProject(id);
        public void updateExistingProject(Project project) throws SQLException {
            String query =
                "UPDATE Projects SET name = '" + project.getName() +
                    "' WHERE id = " + project.getId();
            statement.execute(query);
            projects.getProject(project.getId()).setName(project.getName());
    }So the first question I have is: is this appropriate? I've set up the data access object correctly? I feel like I'm basically reproducing the Projects class... do I even need this class anymore? I certainly don't use it in any of the JSP pages (as you will see).
    Also, I've simply added it to the application context here. Is that the correct way to create and access a data access object like this one?
    The second question is: the form's action parameter is a JSP page that acts as a semi-controller, reads the parameters from the form, and passes that information to a class, which then determines where next to send the application. Does this make sense? I'm not really sure of the idea of using a JSP page as a controller, but I don't know any other way to get the results of the form to the controller class.
    Here is the controller JSP, ProjectsController.jsp:
    <%@ page contentType="text/html; charset=UTF-8" %>
    <%@ page pageEncoding="UTF-8" %>
    <jsp:useBean id="projectsDAO"
                 class="com.emptoris.dataAccess.ProjectsDataAccessObject"
                 scope="application" />
    <jsp:useBean id="projectsController"
                 class="com.emptoris.controller.ProjectsController"
                 scope="request">
      <jsp:setProperty name="projectsController" param="action" property="action" />
    </jsp:useBean>
    <jsp:forward page="<%= response.encodeURL(
                               projectsController.getDestinationPage()
                           ) %>" />and here is the ProjectsController class:
    package com.emptoris.controller;
    public class ProjectsController {
        private String action;
        public ProjectsController() {
        public String getDestinationPage() {
            if (action.equals("Add New Project"))
                return "AddProject.jsp";
            else if (action.equals("Edit Project"))
                return "EditProject.jsp";
            else if (action.equals("Delete Project"))
                return "DeleteProject.jsp";
            return null;
        public void setAction(String action) {
            this.action = action;
    }I'll stop there. I think this is enough information to give me feedback on what I've done thus far. If I've been unclear about something, please let me know and I'll fill in the blanks, or post more code if necessary. Also, feel free to comment on other aspects of the design and style that you see in this code; I'm here to learn, so even if I haven't brought it up, that just means I don't yet see the issues of what I've done yet. :)
    Thanks again for all of your help!
    Regards,
    Anthony Frasso

    hi,
    My best advise not to for any IDE.
    If you do all the things manually, you will get the idea of the reason of doing. if you go with IDE, for ex, if you are creating session bean, IDE itself will create some files for you, these things you will not get to know.
    if you create these things manually, usually you will get lot of errors, so you will get lot of experience than using any IDE.
    if you are going to develop any project or application at that time you can use NetBeans or eclipse or some other ide u like.

  • Entity allready exist?

    The first method createWorkTask() from the first code example is in my stateful bean.
    The second method workTaskDTOToWorkTask() is an static method in a java class called Assembler. It just creates entity object from DTO's .
    The third method saveWorktask() is in a stateless bean and it just persists the new WorkTask.
    I get this error:
    nested exception is: javax.ejb.EJBException: See nested exception; nested exception is: org.apache.openjpa.persistence.EntityExistsException: An object of type "entities.WorkTask" with oid "0" already exists in this context; another cannot be persisted. FailedObject: entities.WorkTask@68d668d6
    I'we tried change the methods but still cant find the second object of the same entity... Can anyone see it?
          @Override
    public ProjectDTO createWorkTask(ProjectDTO project, WorktaskDTO worktask)throws InvalidProjectException, InvalidWorkTaskException, InvalidUserException {
         WorkTask wt = Assembler.workTaskDTOToWorkTask(project, worktask, em);
         Project p = defineTaskUseCase.saveWorktask(wt, project.getId());
         return Assembler.detailedProjectToProjectDTO(p, em);
    public static WorkTask workTaskDTOToWorkTask(ProjectDTO main, WorktaskDTO wt, EntityManager em) throws InvalidWorkTaskException{
              Project project = null;
              try{
                   project = em.find(Project.class, main.getId());
                   if(project == null)
                        throw new InvalidWorkTaskException(1);
                   checkWorkTask(project, wt);
              catch(EJBException ee){throw new InvalidWorkTaskException(3);}
              for (WorkTask w: project.getWorkTasksCollection()) {
                   if(w.getTitle().equalsIgnoreCase(wt.getName()))
                        throw new InvalidWorkTaskException(3);
              WorkTask worktask = new WorkTask();
              worktask.setDetails(wt.getDescription());
              worktask.setTitle(wt.getName());
              worktask.setWorkHoursTotal(wt.getWorkHoursTotal());
              worktask.setWtWeek(wt.getWeek());
              worktask.setWtYear(wt.getYear());
              worktask.setPId(project);
              return worktask;
         public Project saveWorktask(WorkTask wt, int projectId){
              em.persist(wt);
              em.flush();
              return em.find(Project.class, projectId);
         }

    Yes your correct..
    I have a class named "Task" where the other to classes ("Project", "WorkTask") extends. Using Inheritance.
    I've tried to hardcode a WorkTask and persist it, but still gave same fail, unless if i call Entitymanager.clear(). right before i persist, then it works.
    Could it have anything to do with the @id. Why does it work after i clear()? cant find an answer
    @Entity
    @Table(name="TASKS")
    @Inheritance(strategy=InheritanceType.JOINED)
    @DiscriminatorColumn(name="T_TYPE",discriminatorType=DiscriminatorType.STRING)
    @SequenceGenerator(name = "T_SEQ", sequenceName="TASKS_SEQ")
    public abstract class Task implements Serializable {
         @Id
         @Column(name="T_ID")
         @GeneratedValue(strategy=GenerationType.SEQUENCE,generator="T_SEQ")
         private int tId;
    @Entity
    @Table(name="PROJECTS")
    @DiscriminatorValue(value="P")
    public class Project extends Task implements Serializable {
    @Entity
    @Table(name="WORK_TASKS")
    @DiscriminatorValue(value="W")
    public class WorkTask extends Task implements Serializable {

Maybe you are looking for