commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paulo Gaspar" <paulo.gas...@krankikom.de>
Subject RE: Bean storage in database
Date Sat, 02 Feb 2002 23:10:23 GMT
I think that having every other class implementing setXxxxVal() methods
where Xxxx is a type is dreadful.

Are you sure you have to do it like that?

Couldn't you just have a set(Object val) method and an utility class?

I have an utility class (can contribute) for those usual conversions that
goes like this:

  public class CvtHelper
  {
      private final Converter m_converter;

      public CvtHelper(final Converter i_converter)
      {
          m_converter = i_converter;
      }

      public final Object get(final Class i_destClass, final Object i_value)
      {
          return m_converter.converted(i_destClass, i_value);
      }

      public final Object get(final Class i_destClass, final Object i_value,
final Object i_default)
      {
          final Object res = get(i_destClass, i_value);
          return (null != res) ? res : i_default;
      }

      public final Boolean getBoolean(final Object i_value)
      {
          return (Boolean)get(java.lang.Boolean.class, i_value);
      }

      public final Boolean getBoolean(final Object i_value, final Boolean
i_defaultValue)
...
      public final boolean getBoolean(final Object i_value, final boolean
i_defaultValue)
...
      public final Byte getByte(final Object i_value)
...
      public final Byte getByte(final Object i_value, final Byte
i_defaultValue)
...
      public final byte getByte(final Object i_value, final byte
i_defaultValue)
...
  }

It uses a Converter class just as I described during the DynaBean
discussion and avoids having every other class cluttered with a bunch
of getXxxx() or setXxxx() methods.


What do you think?


Have fun,
Paulo Gaspar

http://www.krankikom.de
http://www.ruhronline.de

> -----Original Message-----
> From: Juozas Baliuka [mailto:baliuka@mwm.lt]
> Sent: Saturday, February 02, 2002 6:51 PM
> To: Jakarta Commons Developers List
> Subject: Re: Bean storage in database
>
>
> Hi,
> Yes simpler is good idea, I think abaut the same. Example in simplestore
> uses the same ideas.
> Implementation looks some diferent, but I think we can work together , I
> have the same ideas about transactions, "Value Objects" .... .
>
> Fragment from simpler usage :
> SimperBean newAuthor = simper.create("authors");
>    // Set some properties (this works the same whether creating
> new rows or
> editing existing ones)
>    newAuthor.set("name", name);
>    newAuthor.set("email", email);
>    // Save a message for the JSP page, and show a JSP page
>
> Fragment from simplestore example test:
>
>             TestPersistence testObject;//only interface types supported at
> this time
>             Transaction t =  pm.getTransaction();
>             t.begin();
>             testObject =
> (TestPersistence)pm.createInstance(TestPersistence.class);
>             testObject.setBoolVal(true);
>             testObject.setIntVal(777);
>             assertEquals(testObject.getIntVal(),777);
>             testObject.setStrVal("TEST");
>             testObject.setDateVal(new java.util.Date());
>             testObject.setFloatVal(3f);
>             t.commit();
>
>
> ----- Original Message -----
> From: "Bryan Field-Elliot" <bryan_lists@netmeme.org>
> To: "Jakarta Commons Developers List" <commons-dev@jakarta.apache.org>
> Sent: Saturday, February 02, 2002 4:54 PM
> Subject: Re: Bean storage in database
>
>
>
>
> > Hi Juozas,
> >
> > Before starting your project this weekend, I recommend you have a look
> > at my Simper framework, which does roughly what you describe already.
> > I'm in the process of working with Ted Husted to get it submitted into
> > the sandbox here. In the meantime, take a look at:
> >
> > http://www.netmeme.org/simper
> >
> > Feature highlights include:
> > - Wrapping of table rows using the new DynaBean
> > - Automatic change detection and writing back to database, like EJB CMP
> > - Automatic use of Servlet 2.3 filters to demark transactions (also like
> > EJB entity beans)
> > - Support for relations between table, in a querying capacity (not
> > cascading updates or deletes)
> > - < 1,500 lines of code - simple to understand, yet packs a punch
> > - README describes rationale behind it's design and the tradeoffs made
> > (coming from an EJB CMP perspective)
> >
> > Thanks,
> >
> > Bryan
> >
> >
> > On Sat, 2002-02-02 at 02:03, Juozas Baliuka wrote:
> >
> >     Hi,
> >     this work will be started today. It will be simplestore samples.
> >     I will try to clear my code, it is very dirty and have a lot of bugs
> at
> >     this time.
> >     I decided to implement this for my current project, but I see it can
> be
> >     useful in some more common situations.
> >     I think it is more example for simplestore usage, not any kind of
> framework.
> >     It will be very limited, but it always possible to enhance.
> I will use
> this
> >     for "readonly" data.
> >     like :
> >        CREATE VIEW  MY_STAT AS (  SELECT ID, SUM( SOMETHING ) ,
> >     COUNT(SOMETHING), MAX(SOMETHING)  FROM  MY_TABLE,
> >     ......     WHERE  ........   GROUP BY ID  HAVING ..... ORDER BY
> .    )
> >     I have plans to support "Stored  Procedures" , Transactions,
> >     Finders,  Relations .......... .
> >     But it is not very trivial to implement this stuff on this
> weekend :)
> >
> >
> >
>
>
> --
> To unsubscribe, e-mail:
> <mailto:commons-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:commons-dev-help@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message