ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clinton Begin <clinton.be...@gmail.com>
Subject Re: ibatis 3 basis
Date Wed, 17 Mar 2010 15:49:38 GMT
If there's documentation lacking, please contribute it as per the note
within the first couple of pages of the user guide.



On 2010-03-17, Jon Finanger <jon@finanger.no> wrote:
> Thanks,
> Hmm...missing some letters there I see...
> Got a step further....the 3 version differs a bit from the 2 version I
> realize. Since the version 3 lacks some documentation i learn quite a bit
> from the error messages :-)
>
> -Jon
>
>
> -----Original Message-----
> From: Eduardo M. Cavalcanti [mailto:ecavalcanti@eversystems.com.br]
> Sent: 17. mars 2010 14:59
> To: user-java@ibatis.apache.org
> Subject: Re: ibatis 3 basis
>
> Jon,
> Verify if Account.xml is in correct format. It should contain
>
> <!DOCTYPE mapper
>          PUBLIC "-//ibatis.apache.org//DTD Mapper 3.0//EN"
>          "http://ibatis.apache.org/dtd/ibatis-3-mapper.dtd">
>
> instead of
>
> <!DOCTYPE sqlMap
> PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
> "http://ibatis.apache.org/dtd/sql-map-2.dtd">
>
> to begin with.
>
> Regards.
>
>
> On 17/03/2010 10:39, Jon Finanger wrote:
>> I'm evaluating the technology and have a "tricky" startup problem I'm not
>> able to "see" the solution for.
>> I get the:
>> Exception in thread "main" org.apache.ibatis.exceptions.IbatisException:
>> ### Error building SqlSession.
>> ### The error may exist in test/ibatis/Account.xml
>> ### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL
>> Mapper Configuration.
>> Cause: java.lang.RuntimeException: Error parsing Mapper XML. Cause:
>> java.lang.NullPointerException
>>          at
>>
> org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory
>> .java:8)
>>          at
>>
> org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBu
>> ilder.java:32)
>>          at
>>
> org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBu
>> ilder.java:15)
>>
>>
>> Well,
>> To start with I use the account table and account.java from the JPetshop
>> example as the base (with small mods).
>> Does it exists examplecode for ibatis 3?
>> My testclass is like this:
>>
>> public class Test {
>> 	public static void main(String[] args) {
>> 		String resource = " test/ibatis/SqlMapperConfig.xml";
>> 		Reader reader = null;
>> 		try {
>> 			reader = Resources.getResourceAsReader(resource);
>> 		} catch (IOException e) {}
>> 		SqlSessionFactoryBuilder builder = new
>> SqlSessionFactoryBuilder();
>> 		SqlSessionFactory factory = builder.build(reader);
>> 		SqlSession session = factory.openSession();
>> 		try {
>> 			Account account = new Account();
>> 			account.setAddress1("test address");
>> 			account.setCity("Trondheim");
>> 			account.setEmail("test@test.no");
>> 			account.setFirstName("Jon");
>> 			account.setLastName("XYZ");
>> 			session.insert("insertAccount", account);
>> 			session.commit();
>>
>> 		} finally {
>> 			session.close();
>> 		}
>>
>> 	}
>> }
>>
>>
>> Then I set up the sqlmapperconfig.xml file like this:
>> <?xml  version="1.0"  encoding="UTF-8"  ?>
>> <!DOCTYPE  configuration  PUBLIC
>> "-//ibatis.apache.org//DTD  Config  3.0//EN"
>> "http://ibatis.apache.org/dtd/ibatis-3-config.dtd">
>> <configuration>
>>    <environments  default="development">
>>      <environment  id="development">
>> 	....
>>      </environment>
>>    </environments>
>>    <mappers>
>>      <mapper  resource=" test/ibatis/Account.xml"/>
>>    </mappers>
>> </configuration>
>>
>> The account.xml is like this (2.0 way):
>>
>> <?xml version="1.0" encoding="UTF-8" ?>
>>
>> <!DOCTYPE sqlMap
>> PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"
>> "http://ibatis.apache.org/dtd/sql-map-2.dtd">
>>
>> <sqlMap namespace="Account">
>>
>>    <typeAlias type="tagsmart.test.ibatis.Account" alias="account" />
>>
>>    <select id="getAccountByUsername" resultClass="account"
>> parameterClass="string">
>>      SELECT
>>            ACCOUNT.EMAIL,
>>            ACCOUNT.FIRSTNAME,
>>            ACCOUNT.LASTNAME,
>>            ACCOUNT.STATUS,
>>            ACCOUNT.ADDR1 AS address1,
>>            ACCOUNT.ADDR2 AS address2,
>>            ACCOUNT.CITY,
>>            ACCOUNT.STATE,
>>            ACCOUNT.ZIP,
>>            ACCOUNT.COUNTRY,
>>            ACCOUNT.PHONE,
>>      FROM ACCOUNT
>>      WHERE ACCOUNT.USERID = #username#
>>    </select>
>> .........
>> .......
>>
>> </sqlMap>
>>
>> I've tried to use the 3.0 descriptor, but it complains about sqlMap
>> declaration
>>
>> Any ideas?
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
>> For additional commands, e-mail: user-java-help@ibatis.apache.org
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>

-- 
Sent from my mobile device

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
For additional commands, e-mail: user-java-help@ibatis.apache.org


Mime
View raw message