[weld-dev] SQL framework proof of concept

Arbi Sookazian asookazian at gmail.com
Fri Nov 27 21:44:58 EST 2009


Following comments apply to seam-sql5 rev...

1) In Tuple class:

public <T> T get(int column, Type<T> type) {
        return (T) get(column);
    }

The type param is not referenced in the body of the method.  Why?

2) So I added this method in the Tuple class:

@SuppressWarnings("unchecked")
    public <T> T testGet(int column) {
        return (T) get(column);
    }

  And changed testQuery3() to this:

public static void testQuery3(Session session) {
        System.out.println("begin testQuery3()");
        Iterable<Tuple> result = session.prepareQuery("select username,
name, password, age from users where username=?")
            .set(0, "gavin", VARCHAR)
            .result();

        for (Tuple tuple: result) {
            System.out.println( tuple.testGet(0));
            System.out.println( tuple.testGet(1));
            System.out.println( tuple.testGet(2));
            System.out.println( tuple.testGet(3));
        }
    }

And got the same results in the console.  I don't like to be forced to pass
the datatype in the get() method for Tuple, that should not be requierd.

3) This is looking pretty good to me now in terms of conciseness and
clarity:

@Inject LoginQuery loginQuery;

    public void testLoginQuery(Session session) {

       Iterable<Tuple> result =
session.prepare(loginQuery).set(loginQuery.username,
"gavin").set(loginQuery.password, "foobax").result();

        for (Tuple tuple: result) {
            System.out.println( tuple.get(loginQuery.name) + ' ' +
tuple.get(loginQuery.age)
+ ' ' + tuple.get(loginQuery.permissionId) );
        }
    }

I need to take the time (when I have some!) to look at this API in detail
but the latest rev's addition of sql string as param to query exec is a nice
addition.  Good job!

On Fri, Nov 27, 2009 at 3:16 PM, Gavin King <gavin.king at gmail.com> wrote:

> New rev, with ability to pass SQL as strings.
>
> On Fri, Nov 27, 2009 at 4:47 PM, Gavin King <gavin.king at gmail.com> wrote:
> > Latest, with a new approach to specifying types.
> >
>
>
>
> --
> Gavin King
> gavin.king at gmail.com
> http://in.relation.to/Bloggers/Gavin
> http://hibernate.org
> http://seamframework.org
>
> _______________________________________________
> weld-dev mailing list
> weld-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/weld-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/weld-dev/attachments/20091127/4c99ccb4/attachment.html 


More information about the weld-dev mailing list