You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tuscany.apache.org by lizt <li...@hollycrm.com> on 2007/06/25 09:10:31 UTC

Can I use das.applyChanges(newDataobject) to insert a new dataObject?

Dear team,
    I want use das to implement a general create method like in Hibernate.
I get java.lang.NullPointerException
 at org.apache.tuscany.das.rdb.impl.ApplyChangesCommandImpl.execute(ApplyChangesCommandImpl.java:59)
 at org.apache.tuscany.das.rdb.impl.DASImpl.applyChanges(DASImpl.java:244)
 at com.hollycrm.platform.dao.impl.TuscanyEntityDaoImpl$1.doInConnection(TuscanyEntityDaoImpl.java:30)
 at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:230)
 at com.hollycrm.platform.dao.impl.TuscanyEntityDaoImpl.add(TuscanyEntityDaoImpl.java:26)
 at com.hollycrm.platform.dao.impl.TuscanyEntityDaoImplTest.testAdd(TuscanyEntityDaoImplTest.java:43)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 at java.lang.reflect.Method.invoke(Method.java:585)
 at junit.framework.TestCase.runTest(TestCase.java:154)
 at junit.framework.TestCase.runBare(TestCase.java:127)
 at junit.framework.TestResult$1.protect(TestResult.java:106)
 at junit.framework.TestResult.runProtected(TestResult.java:124)
 at junit.framework.TestResult.run(TestResult.java:109)
 at junit.framework.TestCase.run(TestCase.java:118)
 at junit.framework.TestSuite.runTest(TestSuite.java:208)
 at junit.framework.TestSuite.run(TestSuite.java:203)
 at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
 at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
 at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
when I test a example as follow:
...
public void testAdd() throws Exception{
        InputStream is = ClassLoader.getSystemResourceAsStream("company.xsd");
        List types = XSDHelper.INSTANCE.define(is, null);      
        is.close();
        Type companyType = TypeHelper.INSTANCE.getType("company.xsd", "CompanyType");
        DataObject company = DataFactory.INSTANCE.create(companyType);            

     company.setString("name", "ACME");
     company.setString("id", "E0001");
     dao.add(company);
 }
...
public void add(final DataObject object) {
  this.getJdbcTemplate().execute(new ConnectionCallback(){
   public Object doInConnection(Connection conn) throws SQLException, DataAccessException {
    conn.setAutoCommit(false);
    DAS das = DAS.FACTORY.createDAS(getConfig(object), conn);
    das.applyChanges(object);
    return object;
   }
  });

 }

How can I correct it? 
3ks

lazet
2007/06/25

Re: Can I use das.applyChanges(newDataobject) to insert a new dataObject?

Posted by Luciano Resende <lu...@gmail.com>.
Please take a quick look at :
http://incubator.apache.org/tuscany/workingwithbasiccrud.html

Let me know if you still have problems after that...

On 6/25/07, lizt <li...@hollycrm.com> wrote:
> Dear team,
>     I want use das to implement a general create method like in Hibernate.
> I get java.lang.NullPointerException
>  at org.apache.tuscany.das.rdb.impl.ApplyChangesCommandImpl.execute(ApplyChangesCommandImpl.java:59)
>  at org.apache.tuscany.das.rdb.impl.DASImpl.applyChanges(DASImpl.java:244)
>  at com.hollycrm.platform.dao.impl.TuscanyEntityDaoImpl$1.doInConnection(TuscanyEntityDaoImpl.java:30)
>  at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:230)
>  at com.hollycrm.platform.dao.impl.TuscanyEntityDaoImpl.add(TuscanyEntityDaoImpl.java:26)
>  at com.hollycrm.platform.dao.impl.TuscanyEntityDaoImplTest.testAdd(TuscanyEntityDaoImplTest.java:43)
>  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>  at java.lang.reflect.Method.invoke(Method.java:585)
>  at junit.framework.TestCase.runTest(TestCase.java:154)
>  at junit.framework.TestCase.runBare(TestCase.java:127)
>  at junit.framework.TestResult$1.protect(TestResult.java:106)
>  at junit.framework.TestResult.runProtected(TestResult.java:124)
>  at junit.framework.TestResult.run(TestResult.java:109)
>  at junit.framework.TestCase.run(TestCase.java:118)
>  at junit.framework.TestSuite.runTest(TestSuite.java:208)
>  at junit.framework.TestSuite.run(TestSuite.java:203)
>  at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
>  at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
>  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
>  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
>  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
> when I test a example as follow:
> ...
> public void testAdd() throws Exception{
>         InputStream is = ClassLoader.getSystemResourceAsStream("company.xsd");
>         List types = XSDHelper.INSTANCE.define(is, null);
>         is.close();
>         Type companyType = TypeHelper.INSTANCE.getType("company.xsd", "CompanyType");
>         DataObject company = DataFactory.INSTANCE.create(companyType);
>
>      company.setString("name", "ACME");
>      company.setString("id", "E0001");
>      dao.add(company);
>  }
> ...
> public void add(final DataObject object) {
>   this.getJdbcTemplate().execute(new ConnectionCallback(){
>    public Object doInConnection(Connection conn) throws SQLException, DataAccessException {
>     conn.setAutoCommit(false);
>     DAS das = DAS.FACTORY.createDAS(getConfig(object), conn);
>     das.applyChanges(object);
>     return object;
>    }
>   });
>
>  }
>
> How can I correct it?
> 3ks
>
> lazet
> 2007/06/25


-- 
Luciano Resende
Apache Tuscany Committer
http://people.apache.org/~lresende
http://lresende.blogspot.com/

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