ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brice Ruth <bdr...@gmail.com>
Subject Re: Help needed with Postgres Varchar [] -> String [] - Repost
Date Mon, 14 Feb 2005 19:54:20 GMT
Since this is not a standard JDBC type (that I know of), you'll
probably need to write a custom type handler.

Others can correct me if I'm wrong ... but looking through the iBATIS
manual, I don't see any support for that.


On Mon, 14 Feb 2005 14:29:23 -0500, William Harding
<bharding@dcddesigns.com> wrote:
> It is in fact an array of Varchar. Postgres is an object orieanted db so
> it does allow for that. For example (in the code listed below) we want
> to store the candidates languages with them in that row. So a Varchar[]
> array is the best way to deal with it. Otherwise it means setting up a
> foreign keyd table and doing joins, etc.....
> 
> 
> Brice Ruth wrote:
> 
> >So, in Postgres, its an array of Varchar?! That seems awfully odd, but
> >I'm not that familiar with Postgres. If this is not in fact the case,
> >and you're create a Varchar(10) (length of 10) - then that should be
> >mapped to a simple String object, not an Array of String (String[]).
> >
> >Brice
> >
> >
> >On Mon, 14 Feb 2005 12:34:27 -0500, William Harding
> ><bharding@dcddesigns.com> wrote:
> >
> >
> >>*Note* - This is a second submission. I apologize if this is a repeat. I
> >>have been having so many problems with my ISP lately I don't know if
> >>this was ever sent through the first time. **
> >>
> >>Greetings all,
> >>
> >>I have spent the last 2 days researching how to handle the Postgres data
> >>type: VARCHAR[] and how to map it to a String[] with little to no luck.
> >>I am fairly new to iBATIS and I could have easily missed something very
> >>simple.
> >>
> >>Here is what I have.
> >>
> >>My Current mapping is as follows:
> >>
> >><?xml version="1.0" encoding="UTF-8"?>
> >><!DOCTYPE sqlMap PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
> >>"http://www.ibatis.com/dtd/sql-map-2.dtd">
> >>
> >><sqlMap namespace="CandidateInfo">
> >><typeAlias alias="candidateinfo" type="candidateinput.CandidateInfo"/>
> >>
> >><insert id="insertCandidateInfo" parameterClass="candidateinfo">
> >>    INSERT INTO candidate_info (
> >>        c_candidate_id,
> >>        c_f_name, c_m_initial, c_l_name, c_address_line_one,
> >>c_address_line_two, c_city, c_state, c_zipcode,
> >>        c_country, c_email, c_areacode, c_primary_phone,
> >>c_cell_areacode, c_cellphone,  c_biz_areacode,
> >>        c_biz_phone, c_biz_phone_ext, c_lang_spoken,
> >>c_will_work_part_contract,  c_resume_fliename, c_db_entry_date )
> >>    values (
> >>        (select MAX(c_candidate_id) from candidate_info) + 1,
> >>        #FName#, #MI#, #LName#, #addyOne#, #addyTwo#, #city#, #state#,
> >>#zipcode#,
> >>        #country#, #emailAddy#, #homeArea#, #homePhone#, #cellArea#,
> >>#cellPhone#, #workArea#,
> >>        #workPhone#, #workExt#, #languagesSpoken#, #willWorkPartCont#,
> >>#resumeFilename#, current_date )
> >></insert>
> >>
> >></sqlMap>
> >>
> >>The languagesSpoken parameter is a String[10] in the CandidateInfo
> >>object and is a VARCHAR[10] in the Postgresql database. I have tried
> >>various ways of setting the data type and nothing has worked.
> >>
> >>Each time I execute this mapping I get the following error:
> >>
> >>There was a sql Exception:
> >>com.ibatis.common.jdbc.exception.NestedSQLException: --- The error
> >>occurred in CandidateInfo.xml. --- The error occurred while applying a
> >>parameter map. --- Check the insertCandidateInfo-InlineParameterMap. ---
> >>Check the parameter mapping for the 'languagesSpoken' property. ---
> >>Cause: java.lang.NullPointerException Caused by:
> >>java.lang.NullPointerException
> >>
> >>I have done several tests ranging from not setting any of the array
> >>items to filling them all in order to make sure that they are not null.
> >>My only question is how to I go about handling this issue? I have tried
> >>using an <iterator> tag to build the array by hand.
> >>
> >>Is this a mapping issue or quite possibly a data issue? How do I even go
> >>about debugging this?
> >>
> >>Any help would be greatly appreciated.
> >>
> >>Thanks.
> >>
> >>
> >>
> >>
> >
> >
> >
> >
> >
>

Mime
View raw message