Strange behavior with Cayenne

From: Lucas Holt (luk..oolishgames.com)
Date: Thu Sep 10 2009 - 11:07:03 EDT

  • Next message: Michael Gentry: "Re: Strange behavior with Cayenne"

    I have a table, projects, that consistently causes me grief with Cayenne.
    When creating a new object, it seems to work but never changes the state
    of the object in cayenne. Thus, next time I try to do any operation
    requiring commitChanges(), it tries to insert the record again and fails.

    I can't figure out what is wrong. I found that after the commit I can do
    a rollback to clean up the state, but I suspect there's something else
    happening. This was initially occurring with 2.0.4, so I switched over to
    Cayenne 3.0M6 last night. The same behavior is occurring with the new
    version.

    Here's the create code:
    ...
    proj = (Projects) dataContext.newObject(Projects.class);
    proj.setProjectName(projectName);
    proj.setCompany(company);
    proj.setOffice(office);
    proj.setStartDate(startDate);
    dataContext.commitChanges();
    ...

    dataContext is created with dataContext =
    DataContext.getThreadDataContext(); above (and initialized with a filter
    in the servlet container)

    I've used Cayenne Modeler to setup the relationships.

    Here's the map for that table (with only the catalog name changed)

       <db-entity name="projects" catalog="hiddentoprojectinnocent">
                    <db-attribute name="company_id" type="TINYINT"
    isMandatory="true"/>
                    <db-attribute name="office_id" type="SMALLINT"
    isMandatory="true"/>
                    <db-attribute name="project_id" type="BIGINT"
    isPrimaryKey="true" isGenerated="true" isMandatory="true"
    length="10"/>
                    <db-attribute name="project_name" type="VARCHAR"
    isMandatory="true" length="255"/>
                    <db-attribute name="start_date" type="DATE"/>
            </db-entity>

    No cayenne exceptions are getting thrown when I call commitChanges()
    initially.

    The environment is MySQL 5.1.35, Tomcat 6.0.20, Java 6, Apache Click



    This archive was generated by hypermail 2.0.0 : Thu Sep 10 2009 - 11:07:43 EDT