title: Using a PreparedStatement to persist an array of Java Enums to an array of Postgres Enums
body: <p>I have a Java Enum:</p>
  
  <pre><code>public enum Equipment { Hood, Blinkers, ToungTie, CheekPieces, Visor, EyeShield, None;}
  </code></pre>
  
  <p>and a corresponding Postgres enum:</p>
  
  <pre><code>CREATE TYPE equipment AS ENUM ('Hood', 'Blinkers', 'ToungTie', 'CheekPieces', 'Visor', 'EyeShield', 'None');
  </code></pre>
  
  <p>Within my database I have a table which has a column containing an array of "equipment" items:</p>
  
  <pre><code>CREATE TABLE "Entry" (
      id bigint NOT NULL DEFAULT nextval('seq'::regclass),
      "date" character(10) NOT NULL,
      equipment equipment[]
  );
  </code></pre>
  
  <p>And finally when I am running my application I have an array of the "Equipment" enums which I want to persist to the database using a Prepared Statement, and for the life of me I can't figure out how to do it.</p>
  
  <pre><code>StringBuffer sb =  new StringBuffer("insert into \"Entry\" ");
  sb.append("( \"date\", \"equipment \" )");
  sb.append(" values ( ?, ? )");
  PreparedStatement ps = db.prepareStatement(sb.toString());
  
  ps.setString("2010-10-10");
  ps.set???????????
  </code></pre>