pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Guy Rouillier <guyr-ml1@burntmail.com>
To: Craig Ringer <craig@postnewspapers.com.au>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: JPA and desktop apps
Date: Thu, 29 Jul 2010 02:30:49 -0400
Message-ID: <4C512019.9010000@burntmail.com> (raw)
In-Reply-To: <4C50E5B8.7030409@postnewspapers.com.au>
References: <4C47B5F7.4050303@postnewspapers.com.au>
	<i2c31v$elh$1@news.albasani.net>
	<4C4E832B.20101@postnewspapers.com.au>
	<4C4F4313.8090901@burntmail.com>
	<4C50E5B8.7030409@postnewspapers.com.au>

On 7/28/2010 10:21 PM, Craig Ringer wrote:
> On 28/07/10 04:35, Guy Rouillier wrote:
>
>> Our team is proficient in SQL and JDBC, so we wanted something that
>> would take care of all the routine housekeeping but would not be as
>> bloated as JPA or Hibernate.  We settled on MyBatis
>> (http://www.mybatis.org/) formerly iBATIS.
>
> How did you find that it played with Pg features like:
>
> - Custom and domain types
> - User/role security
> - column privileges

Custom types: you can implement your own TypeHandler and simply tell 
MyBatis to use that for specific columns.  I do that, for example, to 
map columns containing foreign key values into Java enums.  The mapping 
works in both directions, so once you've updated the value of a Java 
enum in an object and want to update the DB, MyBatis will map the enum 
back into the proper column value using your TypeHandler.  Of course, 
all the default TypeHandlers are built in.

Per-user logins: I haven't done that in over 10 years, i.e., long before 
I started using MyBatis.  Just about everything I've been working on 
uses web-based GUIs with server-based database interactions.  MyBatis 
comes packaged with 3 DataSource options that all use a single set of 
credentials.  You can provide your own DataSource implementation.

Column privileges: from the way you describe this, it sounds like you 
have some way of identifying which user logons have update rights on 
which columns.  If that is the case, then MyBatis provides minimalist 
conditional expressions.  Here is a ready example from some production code:

    where
       user_id = #{aUserId, javaType=String, jdbcType=VARCHAR}
       <if test="dtStartDate != null">
       and trunc(timestamp) <![CDATA[ >= ]]> trunc(#{dtStartDate, 
javaType=java.util.Date, jdbcType=DATE})
       </if>
       <if test="aiEventType != null">
       and type_id in
          <foreach collection="aiEventType" item="item" open="(" 
separator="," close=")">
          #{item}
          </foreach>
       </if>

The code is for a where clause, but you can do the same thing in the set 
clause of an update.

I'm not a MyBatis developer, just a happy end user.  It works well for 
what it attempts to do.  But it certainly doesn't attempt to do anywhere 
near what JPA or Hibernate does.

-- 
Guy Rouillier



view thread (14+ messages)  latest in thread

Message-ID: <4C512019.9010000@burntmail.com>
Permalink:  ../4C512019.9010000@burntmail.com/
Also on:    postgresql.org/message-id/4C512019.9010000@burntmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: guyr-ml1@burntmail.com, craig@postnewspapers.com.au
  Subject: Re: JPA and desktop apps
  In-Reply-To: <4C512019.9010000@burntmail.com>
  References: <4C47B5F7.4050303@postnewspapers.com.au> <i2c31v$elh$1@news.albasani.net> <4C4E832B.20101@postnewspapers.com.au> <4C4F4313.8090901@burntmail.com> <4C50E5B8.7030409@postnewspapers.com.au> <4C512019.9010000@burntmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox