ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ivan Bojer <ibo...@gmail.com>
Subject Postgresql 8.3 database Enums
Date Tue, 17 Mar 2009 17:19:32 GMT
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)!?

Mime
View raw message