You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tuscany.apache.org by Sam Su <su...@gmail.com> on 2007/01/29 08:11:26 UTC

a bug: insert databoject fail because the Relationship setting

Hi all, I am using static data object,   in my configuration file:

 <Table tableName="CCP_USER" typeName="User">
        <Column columnName="USER_ID" propertyName="userId"
primaryKey="true"/>
        <Column columnName="PASSWORD" propertyName="password"/>
        <Column columnName="NAME" propertyName="name"/>
        <Column columnName="AVAILABLE"
propertyName="available"/>
    </Table>

following code is to add data object to database:

   User user=(User)UserFactory.INSTANCE.createUser();
        user.setUserId("aaabbiiiiiiiiibc");
        user.setPassword("898989");
        user.setName("wo");
        user.setAvailable ("1");

 Connection conn=dataSource.getConnection();
            conn.setAutoCommit(false);
            DAS das=DAS.FACTORY.createDAS(new
ClassPathResource(schemaConfig).getInputStream(),conn);
            Command command= das.getCommand(commandName);
            DataObject root=command.executeQuery();

            if(logger.isDebugEnabled()) logger.debug("dataobject to be
insert:"+object.toString());
            root.getList(object.getType().getName()).add(object);
            das.applyChanges(root);

I works properly. howerver , when I add a Relationship setting to the
configuration file,  there is no  insert operation to be performed since
tuscany does not detected any change on the root databoject.

  <Relationship name="roles" primaryKeyTable="CCP_SERVICE"
foreignKeyTable="CCP_ROLE" many="true">
      <KeyPair primaryKeyColumn="SERVICE_ID" foreignKeyColumn="SERVICE_ID"/>
    </Relationship>

The relationship setting is nothing to do with the CCP_USER table, I am
wondering why.

Re: a bug: insert databoject fail because the Relationship setting

Posted by Luciano Resende <lu...@gmail.com>.
Another think to have in mind, is how you are generating these static types,
look at some documentation on Tuscany SDO website [1] around "Static Code
Generator" and the noNotification option. If that is turned on, then change
summary will not be tracked and applyChanges will perform no updates on your
database.

If you are using similar DEV environment as the one used in Tuscany, you are
probably setting this field in the project pom file, and would do something
like :

 <build>
        <plugins>
              .....
                <configuration>

<schemaFile>${basedir}/src/main/resources/config.xsd</schemaFile>
                    <noNotification>true/false based on the behaviour
wanted</noNotification>
                </configuration>
                <goals>
                    <goal>generate</goal>
                </goals>
                </execution>
            ......

I had a similar issue while updating BigBank code to use more changeSummary
and this worked for me, please check that and let me know if that does not
help.

[1] http://incubator.apache.org/tuscany/java_sdo_overview.html

On 1/29/07, Brent Daniel <br...@gmail.com> wrote:
>
> The DAS will insert objects into the database when it detects a create
> event in the SDO change summary. Because your DataObject was created
> outside of your DataObject tree, I'm guessing that the even will not
> show up in the change summary.
>
>
> On 1/28/07, Sam Su <su...@gmail.com> wrote:
> > Hi all, I am using static data object,   in my configuration file:
> >
> >  <Table tableName="CCP_USER" typeName="User">
> >         <Column columnName="USER_ID" propertyName="userId"
> > primaryKey="true"/>
> >         <Column columnName="PASSWORD" propertyName="password"/>
> >         <Column columnName="NAME" propertyName="name"/>
> >         <Column columnName="AVAILABLE"
> > propertyName="available"/>
> >     </Table>
> >
> > following code is to add data object to database:
> >
> >    User user=(User)UserFactory.INSTANCE.createUser();
> >         user.setUserId("aaabbiiiiiiiiibc");
> >         user.setPassword ("898989");
> >         user.setName("wo");
> >         user.setAvailable ("1");
> >
> >  Connection conn=dataSource.getConnection();
> >             conn.setAutoCommit(false);
> >             DAS das=DAS.FACTORY.createDAS(new
> > ClassPathResource(schemaConfig).getInputStream(),conn);
> >             Command command= das.getCommand(commandName);
> >             DataObject root= command.executeQuery();
> >
> >             if(logger.isDebugEnabled()) logger.debug("dataobject to be
> > insert:"+object.toString());
> >             root.getList(object.getType().getName()).add(object);
> >             das.applyChanges(root);
> >
> > I works properly. howerver , when I add a Relationship setting to the
> > configuration file,  there is no  insert operation to be performed since
> > tuscany does not detected any change on the root databoject.
> >
> >   <Relationship name="roles" primaryKeyTable="CCP_SERVICE"
> > foreignKeyTable="CCP_ROLE" many="true">
> >       <KeyPair primaryKeyColumn="SERVICE_ID"
> foreignKeyColumn="SERVICE_ID"/>
> >     </Relationship>
> >
> > The relationship setting is nothing to do with the CCP_USER table, I am
> > wondering why.
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: tuscany-user-help@ws.apache.org
>
>


-- 
Luciano Resende
http://people.apache.org/~lresende <http://people.apache.org/%7Elresende>

Re: a bug: insert databoject fail because the Relationship setting

Posted by Brent Daniel <br...@gmail.com>.
The DAS will insert objects into the database when it detects a create
event in the SDO change summary. Because your DataObject was created
outside of your DataObject tree, I'm guessing that the even will not
show up in the change summary.


On 1/28/07, Sam Su <su...@gmail.com> wrote:
> Hi all, I am using static data object,   in my configuration file:
>
>  <Table tableName="CCP_USER" typeName="User">
>         <Column columnName="USER_ID" propertyName="userId"
> primaryKey="true"/>
>         <Column columnName="PASSWORD" propertyName="password"/>
>         <Column columnName="NAME" propertyName="name"/>
>         <Column columnName="AVAILABLE"
> propertyName="available"/>
>     </Table>
>
> following code is to add data object to database:
>
>    User user=(User)UserFactory.INSTANCE.createUser();
>         user.setUserId("aaabbiiiiiiiiibc");
>         user.setPassword("898989");
>         user.setName("wo");
>         user.setAvailable ("1");
>
>  Connection conn=dataSource.getConnection();
>             conn.setAutoCommit(false);
>             DAS das=DAS.FACTORY.createDAS(new
> ClassPathResource(schemaConfig).getInputStream(),conn);
>             Command command= das.getCommand(commandName);
>             DataObject root=command.executeQuery();
>
>             if(logger.isDebugEnabled()) logger.debug("dataobject to be
> insert:"+object.toString());
>             root.getList(object.getType().getName()).add(object);
>             das.applyChanges(root);
>
> I works properly. howerver , when I add a Relationship setting to the
> configuration file,  there is no  insert operation to be performed since
> tuscany does not detected any change on the root databoject.
>
>   <Relationship name="roles" primaryKeyTable="CCP_SERVICE"
> foreignKeyTable="CCP_ROLE" many="true">
>       <KeyPair primaryKeyColumn="SERVICE_ID" foreignKeyColumn="SERVICE_ID"/>
>     </Relationship>
>
> The relationship setting is nothing to do with the CCP_USER table, I am
> wondering why.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-user-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-user-help@ws.apache.org