Hi Eike, Could you please submit your code through JIRA? Create a new issue "Swing example", attach a file to it + select "Grant license to ASF for inclusion in ASF works (as per the Apache License §5) "
That way we can include your example code in the empire-db project... https://issues.apache.org/jira/browse/EMPIREDB Thanks for contributing! Francis On Sun, Feb 7, 2010 at 12:42 PM, Eike Kettner <[email protected]> wrote: > Hi Rainer > > sorry for apparently switching the lists... > > I had a look at the example and build a simple spring version from it > (see attachment). Basically I just split up the SampleApp class into > some pieces and let spring reassemble it again. The class EmpireApp > contains all the code from SampleApp. The classes in support package are > needed to have an easy spring integration, and it would be great to have > those classes provided by empiredb :) - maybe in some > empire-db-spring-support subproject... > > The EmpireDriverFactory class creates DBDatabaseDriver instances and I > used the driver classname instead of a provider-string to decide. Reason > to this is that imho I think its easier for people to get the classname > string than an arbitary provider string (I always don't know for example > if it's now "hsql" or "hsqldb", "derby" or maybe "apache-derby". The > classname exactly identifies what I want, it's somewhat similiar to the > *Dialect classes from hibernate.). > > The class EmpireDBException just wraps the EmpireException to integrate > in springs exception hierarchy. Some applications might look > for the base "DataAccessException", so EmpireException extends a spring > exception to fit in this scenario. Another idea would be to provide an > AOP advice that will wrap the EmpireException if it occurs, so the DAO > implementations are free from this code. > > > eike > > > Rainer Döbele wrote: >> Hi Eike, >> >> Yes, if you could have a look at our basic example and tell us whether >> making a spring version of it makes sense, it would be great. >> The basic example can be found in the distribution in >> src/empire-db-examples/empire-db-example-basic folder. >> It contains four code files: >> - SampleApp.java (the main class) >> - SampleBean.java (the bean for the employee entity) >> - SampleConfig.java (the application config bean) >> - SampleDB.java (the Empire-db data model description) >> Together with the config.xml configuration files this sample may be used >> with various databases. Default is HSQLDB. >> >> The focus of the Sample App is to show people what Empire-db can do and to >> provide a basic application outline. >> Now if you could provide us with a similar project that is built on top of >> Spring we would be very gateful. >> >> Let me know if you need any more help? >> Thanks. >> >> Rainer >> >> >> Eike Kettner wrote: >>> Re: Spring Configuration >>> >>> Hello Rainer >>> >>> thank you for your response. I sure like to help, if I can. What did >>> you have in mind? If you like, I could have a look at the example >>> trying to create a spring version of it. >>> >>> regards, eike >>> >>> On [Sun, 31.01.2010 10:44], Rainer Döbele wrote: >>>> Hello Eike, >>>> >>>> thank you very much for your Empire-db Spring tip and we very much >>> appreciate your contribution. >>>> Personally I am not using Spring but I know that many people out >>> there are. >>>> And I think we should give them some aid on how to best bring Empire- >>> db and Spring together. >>>> So what we really need, is an example application that we can supply >>> with our distribution. >>>> My idea is to take the basic example that we have (empire-db-example- >>> basic) and provide a Spring version of it. >>>> Would you be willing to help us here? >>>> It be really great if you would. >>>> >>>> Looking forward to hearing from you. >>>> Best regards >>>> >>>> Rainer >>>> >>>> >>>> Eike Kettner wrote: >>>>> Re: Spring Configuration >>>>> >>>>> >>>>> Hi there >>>>> >>>>> As it happens that i like to use spring :), I might contribute to >>> this >>>>> with something that works for me so far... >>>>> >>>>> as empire-db sits on top of JDBC, all I do is extending Springs >>>>> JDBCDaoSupport (calling it EmpireDaoSupport) and adding some >>> setters >>>>> for the DBDatabase and DBDriver class. In the application context I >>>>> setup the DBDatabaseDriver and my DBDatabase and have them injected >>> in >>>>> any Dao that extends the EmpireDaoSupport class. I have just played >>>>> with it using the BasicDatasource and a >>> DatasourceTransactionManager >>>>> provided by commons-dbcp and spring. The database driver class and >>> the >>>>> JDBC Settings are injected using normal placeholders from some >>>>> configuration file (xml or whatever you like, if it is a >>>>> java.util.Property at the end) - like you'd do it with spring. >>>>> >>>>> more concrete, my spring applicationXyz.xml: >>>>> <xml> >>>>> ... >>>>> <!-- Data Source / DB Settings --> >>>>> <bean id="dataSource" >>> class="org.apache.commons.dbcp.BasicDataSource" >>>>> destroy-method="close"> >>>>> <property name="driverClassName" value="${jdbc.driverClassName}" >>> /> >>>>> <property name="url" value="${jdbc.url}" /> >>>>> <property name="username" value="${jdbc.username}" /> >>>>> <property name="password" value="${jdbc.password}" /> >>>>> </bean> >>>>> >>>>> <!-- Transaction manager for a single JDBC DataSource --> >>>>> <bean id="transactionManager" >>>>> >>> class="org.springframework.jdbc.datasource.DataSourceTransactionManager >>>>> "> >>>>> <constructor-arg ref="dataSource" /> >>>>> </bean> >>>>> <bean id="transactionTemplate" >>>>> >>> class="org.springframework.transaction.support.TransactionTemplate"> >>>>> <property name="transactionManager" ref="transactionManager" /> >>>>> </bean> >>>>> >>>>> <tx:annotation-driven transaction-manager="transactionManager" /> >>>>> >>>>> <bean id="databaseDriver" class="${empiredb.drivername}"> >>>>> <property name="databaseName" value="${empiredb.databasename}" >>> /> >>>>> </bean> >>>>> <!-- this is my DBDatabase subclass --> >>>>> <bean id="ebxDatabase" class="org.eknet.ebx.db.EbxDatabase"> >>>>> </bean> >>>>> >>>>> <bean id="userDao" class="org.eknet.ebx.impl.UserDaoImpl"> >>>>> <property name="dataSource" ref="dataSource" /> >>>>> <property name="database" ref="ebxDatabase" /> >>>>> <property name="databaseDriver" ref="databaseDriver" /> >>>>> </bean> >>>>> >>>>> >>>>> And this is the EmpireDaoSupport class: >>>>> >>>>> public class EmpiredbDaoSupport extends JdbcDaoSupport { >>>>> >>>>> private DBDatabase db; >>>>> private DBDatabaseDriver dbdriver; >>>>> >>>>> public EmpiredbDaoSupport() { >>>>> } >>>>> >>>>> public void setDatabase(DBDatabase db) { >>>>> this.db = db; >>>>> } >>>>> >>>>> public void setDatabaseDriver(DBDatabaseDriver dbdriver) { >>>>> this.dbdriver = dbdriver; >>>>> } >>>>> >>>>> @Override >>>>> protected void checkDaoConfig() { >>>>> super.checkDaoConfig(); >>>>> if (db == null) >>>>> throw new IllegalArgumentException("'database' must be >>> given!"); >>>>> if (dbdriver == null) >>>>> throw new IllegalArgumentException("'databaseDriver' must be >>>>> given!"); >>>>> } >>>>> >>>>> public DBDatabase getDatabase() { >>>>> if (!db.isOpen()) >>>>> db.open(dbdriver, getConnection()); >>>>> return db; >>>>> } >>>>> >>>>> @SuppressWarnings("unchecked") >>>>> public <T extends DBDatabase> T getDB() { >>>>> return (T) getDatabase(); >>>>> } >>>>> >>>>> public DBDatabaseDriver getDatabasedriver() { >>>>> return dbdriver; >>>>> } >>>>> >>>>> public RuntimeException translateEmpireException(EmpireException >>> e) { >>>>> return new >>>>> DataAccessResourceFailureException(e.getLocalizedMessage()); >>>>> } >>>>> >>>>> protected DBReader openReader(DBCommand cmd, Connection conn) { >>>>> DBReader r = new DBReader(); >>>>> r.open(cmd, conn); >>>>> return r; >>>>> } >>>>> >>>>> } >>>>> >>>>> Then implementing any DAO object is the same like with jdbc or >>>>> hibernate - extend the support class and implement it with empire- >>> db: >>>>> public class UserDaoImpl extends EmpiredbDaoSupport implements >>> UserDao >>>>> { >>>>> >>>>> @Override >>>>> public int findAllUserCount() { >>>>> EbxDatabase db = getDB(); >>>>> Connection conn = getConnection(); >>>>> >>>>> UserTable ut = db.TBL_USER; >>>>> DBCommand cmd = db.createCommand(); >>>>> cmd.select(ut.count()); >>>>> ... >>>>> >>>>> } >>>>> >>>>> bye, eike >>>>> >>>>> On [Mon, 04.01.2010 14:23], Jaco van Tonder wrote: >>>>>> Hello guys, >>>>>> >>>>>> I am busy investigating Empire-DB as a replacement for Hibernate >>> in >>>>> our organization (so far so good). :) I have a couple of questions >>>>> though. >>>>>> I put together a config class that does not make use of a config >>> file >>>>> (looked at the examples, and just used the defaults), but instead >>> is >>>>> wired using Spring (simple setter injection). I could not find any >>>>> examples that uses this method so I am not sure if this is the best >>> way >>>>> to do it. I looked at the source code and could not find any other >>> way >>>>> of configuring Empire-DB that is not XML based. >>>>>> Q: Is there a recommended way of configuring Empire-DB using >>> Spring? >>>>>> I read that there is no built-in transaction support. Obviously >>> this >>>>> is important for databases. :) >>>>>> Q: What transaction managers are known to work well with Empire- >>> DB? >>>>> JOTM, etc etc etc? Are there any examples of this available >>> somewhere? >>>>>> I am willing to document any of the answers (ie spring >>> configuration, >>>>> transaction manager examples) on the project wiki. >>>>>> Thank you in advance. >>>>>> >>>>>> ---Jaco >>>>>> >>>>>> >>>>>> >>> ####################################################################### >>>>> ############## >>>>>> Attention: >>>>>> The information contained in this message and or attachments is >>>>> intended >>>>>> only for the person or entity to which it is addressed and may >>>>> contain >>>>>> confidential and/or privileged material. Any review, >>> retransmission, >>>>>> dissemination or other use of, or taking of any action in >>> reliance >>>>> upon, >>>>>> this information by persons or entities other than the intended >>>>> recipient >>>>>> is prohibited. If you received this in error, please contact the >>>>> sender and >>>>>> delete the material from any system and destroy any copies. >>>>>> >>>>>> Thank You. >>>>>> >>> ####################################################################### >>>>> ############## >>>>>> >>> ####################################################################### >>>>> ############## >>>>>> This e-mail message has been scanned for Viruses and Content and >>>>> cleared >>>>>> by MailMarshal >>>>>> >>> ####################################################################### >>>>> ############## >>>>> >>>>> -- >>>>> email: [email protected] https://www.eknet.org pgp: 481161A0 >>> -- >>> email: [email protected] https://www.eknet.org pgp: 481161A0 >> > -- http://www.somatik.be Microsoft gives you windows, Linux gives you the whole house.
