You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Ivan Bojer <ib...@gmail.com> on 2009/03/17 18:19:32 UTC

Postgresql 8.3 database Enums

Does anyone know how to implement databasetype enums in ibatis (NOTE:
This is not the same as implementing Java enums!)
The problem is that IBatis does not know how to insert duplexMode
(typeof: String) into database's suplexMode(typeof: x.duplex_mode)!?

Here is configuration:

I have database schema like this:
--------------------------------------------

CREATE SCHEMA x;

CREATE TYPE x.duplex_mode AS ENUM (
     'Auto',
     'Full Duplex',
     'Half Duplex'
);

CREATE TABLE x.interface (
    ipaddr INET NOT NULL UNIQUE,
    duplexMode x.duplex_mode,
    id BIGSERIAL,
    PRIMARY KEY(id)
);

My IBatis descriptor like this:
---------------------------------------

<sqlMap namespace="Interfaces">

  <insert id="insertInterface" parameterClass="InterfaceBean">
    insert into x.interface (
    	ipaddr, duplexMode
    ) values (
      inet(#ipAddr#),
      #duplexMode#
    )
  </insert>
</sqlMap>


My bean class like this:
-------------------------------

public class InterfaceBean {
	private int id;

	private String ipAddr;
	private String duplexMode;

	public InterfaceBean() {
		super();
	}

	<..all getters and setters...>
}

The problem is that IBatis does not know how to insert duplexMode
(typeof: String) into database's suplexMode(typeof: x.duplex_mode)!?