Skip site navigation (1) Skip section navigation (2)

Re: JPA and desktop apps

From: Guy Rouillier <guyr-ml1(at)burntmail(dot)com>
To: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: JPA and desktop apps
Date: 2010-07-29 06:30:49
Message-ID: 4C512019.9010000@burntmail.com (view raw or flat)
Thread:
Lists: pgsql-jdbc
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

In response to

pgsql-jdbc by date

Next:From: Matthew WakelingDate: 2010-07-29 09:15:14
Subject: Re: [HACKERS] Trouble with COPY IN
Previous:From: Craig RingerDate: 2010-07-29 02:21:44
Subject: Re: JPA and desktop apps

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group