Package org.skife.jdbi.v2.exceptions

Examples of org.skife.jdbi.v2.exceptions.DBIException


     * or a new one otherwise.
     * @param dbi the IDBI instance from which to obtain the handle
     */
    public static Handle getHandle(IDBI dbi)
    {
        Handle bound = (Handle) TransactionSynchronizationManager.getResource(dbi);
        if (bound == null) {
            bound = dbi.open();
            if (TransactionSynchronizationManager.isSynchronizationActive()) {
                TransactionSynchronizationManager.bindResource(dbi, bound);
                TransactionSynchronizationManager.registerSynchronization(new Adapter(dbi, bound));
View Full Code Here


        ParameterizedType returnType = (ParameterizedType) t;
        final Type[] h = returnType.getActualTypeArguments();
        assert(h.length == 1);
        assert(h[0] instanceof Class);
        Class c = (Class) h[0];
        Query q = handle.createQuery(s.value()).map(c);
        if (args != null) bindArguments(method.isAnnotationPresent(BindBy.class) ?
                                        method.getAnnotation(BindBy.class).value() :
                                        BindType.Position, q, args);
        return f.doit(q);
    }
View Full Code Here

    }

    @SuppressWarnings("unchecked")
    private Object handleInstance(Select s, Method method, Object[] args)
    {
        Query q = handle.createQuery(s.value()).map(method.getReturnType());
        if (args != null) bindArguments(method.isAnnotationPresent(BindBy.class) ?
                                        method.getAnnotation(BindBy.class).value() :
                                        BindType.Position, q, args);
        if (args != null) bindArguments(method.isAnnotationPresent(BindBy.class) ?
                                        method.getAnnotation(BindBy.class).value() :
                                        BindType.Position, q, args);
        q.setMaxRows(1);
        return q.first();
    }
View Full Code Here

        List<Something> ds = q.getAllSomethings();

        assertNotNull(ds);
        Iterator<Something> i = ds.iterator();
        assertTrue(i.hasNext());
        Something s = i.next();
        assertEquals("Keith", s.getName());
    }
View Full Code Here

        List<Something> ds = q.findByName("Keith");

        assertNotNull(ds);
        Iterator<Something> i = ds.iterator();
        assertTrue(i.hasNext());
        Something s = i.next();
        assertEquals("Keith", s.getName());
    }
View Full Code Here

    {
        handle.insert("insert into something (id, name) values (?, ?)", 1, "Keith");
        Iterator<Something> i = q.ittyAll();

        assertTrue(i.hasNext());
        Something s = i.next();
        assertEquals("Keith", s.getName());
        assertFalse(i.hasNext());
    }
View Full Code Here

    }

    public void testSingle() throws Exception
    {
        handle.insert("insert into something (id, name) values (?, ?)", 1, "Keith");
        Something s = q.findById(1);
        assertEquals("Keith", s.getName());
    }
View Full Code Here

    public void testInsert() throws Exception
    {
        assertEquals(true, q.insert(1, "Keith"));
        Iterator<Something> as = q.ittyAll();
        assertTrue(as.hasNext());
        Something s = as.next();
        assertEquals("Keith", s.getName());
        assertFalse(as.hasNext());
    }
View Full Code Here

    public void testUpdate() throws Exception
    {
        q.insert(1, "Keith");
        q.updateNameById("Eric", 1);
        Something s = q.findById(1);
        assertNotNull(s);
        assertEquals("Eric", s.getName());
    }
View Full Code Here

        assertFalse(q.ittyAll().hasNext());
    }

    public void testBeanBinding() throws Exception
    {
        Something s = new Something(1, "Keith");
        q.insert(s);

        s = q.findById(1);
        assertNotNull(s);
        assertEquals("Keith", s.getName());

    }
View Full Code Here

TOP

Related Classes of org.skife.jdbi.v2.exceptions.DBIException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.