Hi All,
I have two tables account and address. I have two objects Address.java and Account.java. I am populating the value from address table into Address.java but keeping an instance of Address class in Account.java as �address�. I created the map statements and done all the configurations correctly. I have two xml files both are included in the configuration file also. The map statements are
// Account.xml
<result-map name="account-result" class="examples.domain.Account">
<property name="id" column="ACC_ID" />
<property name="firstName" column="ACC_FIRST_NAME"/>
<property name="lastName" column="ACC_LAST_NAME"/>
<property name="emailAddress" column="ACC_EMAIL" null="no_email@provided.com"/>
<property name="address" column="ACC_ID" mapped-statement="getAddressForAccount" />
</result-map>
<mapped-statement name="getAccounts" cache-model="account-cache" result-map="account-result">
select * from ACCOUNT
where ACC_ID = #value#
</mapped-statement>
//Address.xml
<mapped-statement name="getAddressForAccount"
result-class="examples.domain.Address">
select
ADR_ID as id,
ADR_DESCRIPTION as description,
ADR_STREET as street,
ADR_CITY as city,
ADR_PROVINCE as province,
ADR_POSTAL_CODE as postalCode
from ADDRESS
where ADR_ACC_ID = #value#
</mapped-statement>
The tables are
CREATE TABLE ACCOUNT (
ACC_ID INTEGER NOT NULL,
ACC_FIRST_NAME TEXT,
ACC_LAST_NAME TEXT,
ACC_EMAIL TEXT,
PRIMARY KEY (ACC_ID)
);
CREATE TABLE ADDRESS (
ADR_ID INTEGER NOT NULL,
ADR_ACC_ID INTEGER NOT NULL,
ADR_DESCRIPTION TEXT,
ADR_STREET TEXT,
ADR_CITY TEXT,
ADR_PROVINCE TEXT,
ADR_POSTAL_CODE TEXT,
PRIMARY KEY (ADR_ID)
);
The java statement is
List list = sqlMap.executeQueryForList("getAccounts", new Integer(1));
it is showing the error as
ERROR [main] - Error executing 'getAccounts' in 'examples/sqlmap/maps/Account.xml'. Check the Result Map. Check the 'address' property. Cause: java.sql.SQLException: No data found
java.sql.SQLException: No data found
at com.ibatis.db.sqlmap.MappedStatement.runQueryForList(MappedStatement.java:677)
at com.ibatis.db.sqlmap.MappedStatement.executeQueryForList(MappedStatement.java:581)
at com.ibatis.db.sqlmap.MappedStatement.executeQueryForList(MappedStatement.java:561)
at com.ibatis.db.sqlmap.SqlMap.executeQueryForList(SqlMap.java:784)
at examples.sqlmap.QueryForListExample.queryForListExample(QueryForListExample.java:30)
at examples.sqlmap.QueryForListExample.main(QueryForListExample.java:66)
Exception : java.sql.SQLException: No data found
Can anybody please let me know about the actual problem that I am facing. I need to do it in my realtime application and to move it in production. So please let me know about the problem ASAP. I need the two different queries from different tables combined in one Object.
Any help will be appreciable
Regards,
PRINCE V. K.