Re: JPA and desktop apps
От | Guy Rouillier |
---|---|
Тема | Re: JPA and desktop apps |
Дата | |
Msg-id | [email protected] обсуждение исходный текст |
Ответ на | Re: JPA and desktop apps (Craig Ringer <[email protected]>) |
Список | 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
В списке pgsql-jdbc по дате отправления: