Hi there,


I have service method createTestData() which should do something like this:



protected void handleCreateTestData() throws java.lang.Exception {

    try { 

      this.getFirstDao().createTestData();

    } catch (Exception ex) {

      CustomLogger.error("Failed while creating First 
entities!", ex);

    }

    try { 

      this.getSecondDao().createTestData();

    } catch (Exception ex) {

      CustomLogger.error("Failed while creating Second 
entities!", ex);

    }

..... etc...



}



createTestData in DAO impls look like this:



  protected void handleCreateTestData() throws Exception {

    Session s = this.getSession();

    try {

      CustomLogger.info("creating currencies...");

      CustomLogger.info("PLNs:");

      Currency curPLN = new CurrencyImpl();

      
curPLN.setCurrencyId(MassolitConstants.CURRENCY_PLN);

      curPLN.setAbbrev("PLN");

      curPLN.setName("Polish Zloty");

      curPLN.setPlnEquiv((float) 1.0);

      this.create(curPLN);

      CustomLogger.info("PLN - created");



      CustomLogger.info("EUROs:");

      Currency curEUR = new CurrencyImpl();

      
curEUR.setCurrencyId(MassolitConstants.CURRENCY_EUR);

      curEUR.setAbbrev("EUR");

      curEUR.setName("Euro");

      curEUR.setPlnEquiv((float) 4.23);

      this.create(curEUR);

      CustomLogger.info("Euro created");





      CustomLogger.info("USDs:");

      Currency curUSD = new CurrencyImpl();

      
curUSD.setCurrencyId(MassolitConstants.CURRENCY_USD);

      curUSD.setAbbrev("USD");

      curUSD.setName("US Dollars");

      curUSD.setPlnEquiv((float) 3.84);

      this.create(curUSD);

      CustomLogger.info("USDs created");



      CustomLogger.info("Flushing session...");

      s.flush();

      CustomLogger.info("Session flushed. Finished adding 
currencies.");

    } catch (Exception ex) {

      CustomLogger.error("FAILED while adding currencies!", 
ex);

      s.clear();

    }





  }



it's working, but:

1. I got such an info after calling this method:

15:12:58,180 INFO  [massolit] Session flushed. Finished 
adding currencies.

15:12:58,230 INFO  [CachedConnectionManager] Closing a 
connection for you.  Plea

se close them yourself: [EMAIL PROTECTED]



java.lang.Exception: STACKTRACE

        at 
org.jboss.resource.connectionmanager.CachedConnectionManager.register

Connection(CachedConnectionManager.java:321)

        at 
org.jboss.resource.connectionmanager.BaseConnectionManager2.allocateC

onnection(BaseConnectionManager2.java:467)

        at 
org.jboss.resource.connectionmanager.BaseConnectionManager2$Connectio

nManagerProxy.allocateConnection(BaseConnectionManager2.java:874)

        at 
org.jboss.resource.adapter.jdbc.WrapperDataSource.getConnection(Wrapp

erDataSource.java:103)

        at 
org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.

getConnection(LocalDataSourceConnectionProvider.java:80)

        at 
org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager

.java:298)



2. I am not using managed transactions... The question is: how can I use 
managed transactions here in such a way, that:

a. I can choose at service.createTestData() method level what kind of 
exceptions should cause operation rollback

b. I can still log those exceptions in some way for future debugging?



Thanx
_________________________________________________________
Reply to the post : http://galaxy.andromda.org/forum/viewtopic.php?p=2513#2513
Posting to http://forum.andromda.org/ is preferred over posting to the mailing 
list!


-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP, 
AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
Andromda-user mailing list
Andromda-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/andromda-user

Reply via email to