When i run insert query through unit testing,i get below exception
org.apache.ibatis.exceptions.IbatisException: ### Error updating database. Cause: org.apache.ibatis.reflection.ReflectionException: *There is no getter for property named 'empNumber' in 'class java.util.ArrayList'* ### The error may involve WorkplaceDetail.insertWorkplace-Inline ### The error occurred while setting parameters ### Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'empNumber' in 'class java.util.ArrayList' at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactor y.java:8) at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSessi on.java:100)
Below is my configuration of workplace.xml where i have highlighted insert statement.
<insert id="insertWorkplace" parameterType ="WorkplaceDetail" useGeneratedKeys="true"> <selectKey resultType="int" keyProperty="code" order="BEFORE"> select last_insert_rowId() as code </selectKey> * INSERT INTO Workplace (WRegNum,WorkplaceName,EmpNumber,AddressId,notes1) SELECT #{compRegNum}, #{plant}, #{employee.empNumber}, #{address.addressId}, #{note1} FROM Workplace inner join Employee on (Workplace.[EmpNumber]={employee.empNumber}) inner join Address on (Workplace.[AddressID]= #{address.addressId});* </insert>
public class WorkplaceDetail{ private int code; private String plant; private String compRegNum;private List <Employee> employee = new ArrayList<Employee>(); private Address address;
I’m not sure of what your trying to do, but many things seem wrong with your query.
First, using SELECT #{xyz} seems wrong since you probably want the content of your Employee/Address tables as values to insert.
Second, it’s impossible to resolve the property of a list using the dot notation. So employee.empNumber is impossible since employee is a list and lists don’t have a empNumber property. You may wish to use <foreach> tag as defined here: http://www.mybatis.org/core/dynamic-sql.html
Look at this example:
http://www.mybatis.org/core/sqlmap-xml.html#insert_update_and_delete <insert id="insertAuthor" parameterType="domain.blog.Author">
insert into Author (id,username,password,email,bio)
values (#{id},#{username},#{password},#{email},#{bio})
</insert>
Christian
De : mybatis-user@googlegroups.com [mailto:mybatis-user@googlegroups.com] De la part de PP
Envoyé : November-14-12 11:15 PM
À : mybatis-user@googlegroups.com
Objet : ### Error updating database. Cause: org.apache.ibatis.reflection.ReflectionException - iBatis
Hi All,
When i run insert query through unit testing,i get below exception
org.apache.ibatis.exceptions.IbatisException:
### Error updating database. Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'empNumber' in 'class java.util.ArrayList'
### The error may involve WorkplaceDetail.insertWorkplace-Inline
### The error occurred while setting parameters
### Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'empNumber' in 'class java.util.ArrayList'
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactor y.java:8)
at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSessi on.java:100)
Below is my configuration of workplace.xml where i have highlighted insert statement.
Yes you are true...i am trying to "First, using SELECT #{xyz} seems wrong since you probably want the content of your Employee/Address tables as values to insert."
I will try to do as you suggested...
On Thursday, November 15, 2012 10:44:49 PM UTC+9, christia...@ircm.qc.ca wrote:
> I’m not sure of what your trying to do, but many things seem wrong with > your query.
> First, using SELECT #{xyz} seems wrong since you probably want the content > of your Employee/Address tables as values to insert.
> Second, it’s impossible to resolve the property of a list using the dot > notation. So employee.empNumber is impossible since employee is a list and > lists don’t have a empNumber property. You may wish to use <foreach> tag as > defined here: http://www.mybatis.org/core/dynamic-sql.html
> When i run insert query through unit testing,i get below exception
> org.apache.ibatis.exceptions.IbatisException:
> ### Error updating database. Cause: org.apache.ibatis.reflection.ReflectionException: *There is no getter for property named 'empNumber' in 'class java.util.ArrayList'*
> ### The error may involve WorkplaceDetail.insertWorkplace-Inline
> ### The error occurred while setting parameters
> ### Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'empNumber' in 'class java.util.ArrayList'
> at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactor y.java:8)
> at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSessi on.java:100)
> Below is my configuration of workplace.xml where i have highlighted insert > statement.
So does this mean that i have to write separate insert query for Workplace, Employee and Address and then populate in table using select joins. Please confirm. And in DAO implementation how should i process insert method.
On Thursday, November 15, 2012 10:44:49 PM UTC+9, christia...@ircm.qc.ca wrote:
> I’m not sure of what your trying to do, but many things seem wrong with > your query.
> First, using SELECT #{xyz} seems wrong since you probably want the content > of your Employee/Address tables as values to insert.
> Second, it’s impossible to resolve the property of a list using the dot > notation. So employee.empNumber is impossible since employee is a list and > lists don’t have a empNumber property. You may wish to use <foreach> tag as > defined here: http://www.mybatis.org/core/dynamic-sql.html
> When i run insert query through unit testing,i get below exception
> org.apache.ibatis.exceptions.IbatisException:
> ### Error updating database. Cause: org.apache.ibatis.reflection.ReflectionException: *There is no getter for property named 'empNumber' in 'class java.util.ArrayList'*
> ### The error may involve WorkplaceDetail.insertWorkplace-Inline
> ### The error occurred while setting parameters
> ### Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'empNumber' in 'class java.util.ArrayList'
> at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactor y.java:8)
> at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSessi on.java:100)
> Below is my configuration of workplace.xml where i have highlighted insert > statement.
On Thursday, November 15, 2012 1:15:17 PM UTC+9, PP wrote:
> Hi All,
> When i run insert query through unit testing,i get below exception
> org.apache.ibatis.exceptions.IbatisException: > ### Error updating database. Cause: org.apache.ibatis.reflection.ReflectionException: *There is no getter for property named 'empNumber' in 'class java.util.ArrayList'* > ### The error may involve WorkplaceDetail.insertWorkplace-Inline > ### The error occurred while setting parameters > ### Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'empNumber' in 'class java.util.ArrayList' > at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactor y.java:8) > at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSessi on.java:100)
> Below is my configuration of workplace.xml where i have highlighted insert > statement.
> Hi all, please suggest me alternate way to handle this...issue
> On Thursday, November 15, 2012 1:15:17 PM UTC+9, PP wrote:
> Hi All,
> When i run insert query through unit testing,i get below exception
> |org.apache.ibatis.exceptions.IbatisException:
> ### Error updating database. Cause: org.apache.ibatis.reflection.ReflectionException:*There is no getter for property named 'empNumber' in 'class java.util.ArrayList'*
> ### The error may involve WorkplaceDetail.insertWorkplace-Inline
> ### The error occurred while setting parameters
> ### Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'empNumber' in 'class java.util.ArrayList'
> at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactor y.java:8)
> at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSessi on.java:100)
> |
> Below is my configuration of workplace.xml where i have highlighted
> insert statement.
The error is here - you are missing the "#" before the squiggle bracket. However, I'm not following what you are trying to accomplish with this select statement. Your select list is being filled with values from your parameter, i.e., constants.
Basically i want to the content of your Employee/Address tables as values to insert of Workplace table. My actual scenario is...i have one table at GUI which gets populated from different DB tables and also insert . I don have issue with select...but insert operation i am facing issue..it is like 1+N insert.
On Wednesday, November 21, 2012 9:01:38 AM UTC+9, Guy wrote:
> On 11/19/2012 8:11 PM, PP wrote: > > Hi all, please suggest me alternate way to handle this...issue
> > On Thursday, November 15, 2012 1:15:17 PM UTC+9, PP wrote:
> > Hi All,
> > When i run insert query through unit testing,i get below exception
> > |org.apache.ibatis.exceptions.IbatisException: > > ### Error updating database. Cause: > org.apache.ibatis.reflection.ReflectionException:*There is no getter for > property named 'empNumber' in 'class java.util.ArrayList'* > > ### The error may involve WorkplaceDetail.insertWorkplace-Inline > > ### The error occurred while setting parameters > > ### Cause: org.apache.ibatis.reflection.ReflectionException: There > is no getter for property named 'empNumber' in 'class java.util.ArrayList' > > at > org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactor y.java:8)
> > at > org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSessi on.java:100)
> > |
> > Below is my configuration of workplace.xml where i have highlighted > > insert statement.
> The error is here - you are missing the "#" before the squiggle bracket. > However, I'm not following what you are trying to accomplish with this > select statement. Your select list is being filled with values from your > parameter, i.e., constants.
> Basically i want to the content of your Employee/Address tables as
> values to insert of Workplace table. My actual scenario is...i have
> one table at GUI which gets populated from different DB tables and also
> insert . I don have issue with select...but insert operation i am facing
> issue..it is like 1+N insert.
Why can't you do this with a insert-select statement? I see that is what you have in your original post, but you have all MyBatis parameter markers in your SELECT statement, e.g., #{compRegNum}. Because you have those, you are selecting all constant values. If you want to do that, you don't need the SELECT at all; just put the MyBatis parameter markers into the values clause for the insert.
But from your description, what you really want to do is a simple insert select, where the items in the select list are columns from the source table.
Sorry, this is all I can say unless you can clarify your scenario better. If you have a bunch of rows in a GUI which need to get inserted into a table, then iterate over those rows and invoke a simple insert statement each iteration, inserting a single row; using MyBatis parameter markers for the values clause in that insert statement.
> On Wednesday, November 21, 2012 9:01:38 AM UTC+9, Guy wrote:
> On 11/19/2012 8:11 PM, PP wrote:
> > Hi all, please suggest me alternate way to handle this...issue
> > On Thursday, November 15, 2012 1:15:17 PM UTC+9, PP wrote:
> > Hi All,
> > When i run insert query through unit testing,i get below
> exception
> > |org.apache.ibatis.exceptions.IbatisException:
> > ### Error updating database. Cause:
> org.apache.ibatis.reflection.ReflectionException:*There is no getter
> for property named 'empNumber' in 'class java.util.ArrayList'*
> > ### The error may involve WorkplaceDetail.insertWorkplace-Inline
> > ### The error occurred while setting parameters
> > ### Cause: org.apache.ibatis.reflection.ReflectionException:
> There is no getter for property named 'empNumber' in 'class
> java.util.ArrayList'
> > at
> org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactor y.java:8)
> > at
> org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSessi on.java:100)
> > |
> > Below is my configuration of workplace.xml where i have
> highlighted
> > insert statement.
> The error is here - you are missing the "#" before the squiggle
> bracket.
> However, I'm not following what you are trying to accomplish with
> this
> select statement. Your select list is being filled with values from
> your
> parameter, i.e., constants.
<insert id="insertWorkspace" parameterType="WorkspaceDetail">
INSERT INTO Workspace
SELECT comRegNum, plant, empNumber, addressId, note1
FROM Employee
JOIN Address ON Employee.id = Address.empId
WHERE Employee.id IN (
<forEach item="emp" collection="employee" separator=",">
#{emp.id}
</forEach>
)
</insert>
But, doing such a select will make it impossible for MyBatis to set the id in the WorspaceDetail since more than one row is inserted.
If you need the id supplied by the database, then you have to insert each row one by one. The iteration will then be in your service class and the insert will be trivial like this one.
<insert id="insertAuthor" parameterType="domain.blog.Author">
insert into Author (id,username,password,email,bio)
values (#{id},#{username},#{password},#{email},#{bio})
</insert>
Christian
-----Message d'origine-----
De : mybatis-user@googlegroups.com [mailto:mybatis-user@googlegroups.com] De la part de Guy Rouillier
Envoyé : November-21-12 12:38 AM
À : mybatis-user@googlegroups.com
Objet : Re: ### Error updating database. Cause: org.apache.ibatis.reflection.ReflectionException - iBatis
On 11/20/2012 10:23 PM, PP wrote:
> Basically i want to the content of your Employee/Address tables as > values to insert of Workplace table. My actual scenario is...i have > one table at GUI which gets populated from different DB tables and > also insert . I don have issue with select...but insert operation i am > facing issue..it is like 1+N insert.
Why can't you do this with a insert-select statement? I see that is what you have in your original post, but you have all MyBatis parameter markers in your SELECT statement, e.g., #{compRegNum}. Because you have those, you are selecting all constant values. If you want to do that, you don't need the SELECT at all; just put the MyBatis parameter markers into the values clause for the insert.
But from your description, what you really want to do is a simple insert select, where the items in the select list are columns from the source table.
Sorry, this is all I can say unless you can clarify your scenario better. If you have a bunch of rows in a GUI which need to get inserted into a table, then iterate over those rows and invoke a simple insert statement each iteration, inserting a single row; using MyBatis parameter markers for the values clause in that insert statement.
> On Wednesday, November 21, 2012 9:01:38 AM UTC+9, Guy wrote:
> On 11/19/2012 8:11 PM, PP wrote:
> > Hi all, please suggest me alternate way to handle this...issue
> > On Thursday, November 15, 2012 1:15:17 PM UTC+9, PP wrote:
> > Hi All,
> > When i run insert query through unit testing,i get below
> exception
> > |org.apache.ibatis.exceptions.IbatisException:
> > ### Error updating database. Cause:
> org.apache.ibatis.reflection.ReflectionException:*There is no getter
> for property named 'empNumber' in 'class java.util.ArrayList'*
> > ### The error may involve WorkplaceDetail.insertWorkplace-Inline
> > ### The error occurred while setting parameters
> > ### Cause: org.apache.ibatis.reflection.ReflectionException:
> There is no getter for property named 'empNumber' in 'class
> java.util.ArrayList'
> > at
> The error is here - you are missing the "#" before the squiggle
> bracket.
> However, I'm not following what you are trying to accomplish with
> this
> select statement. Your select list is being filled with values from
> your
> parameter, i.e., constants.
> <insert id="insertWorkspace" parameterType="WorkspaceDetail"> > INSERT INTO Workspace > SELECT comRegNum, plant, empNumber, addressId, note1 > FROM Employee > JOIN Address ON Employee.id = Address.empId > WHERE Employee.id IN ( > <forEach item="emp" collection="employee" separator=","> > #{emp.id} > </forEach> > ) > </insert>
> But, doing such a select will make it impossible for MyBatis to set the id > in the WorspaceDetail since more than one row is inserted. > If you need the id supplied by the database, then you have to insert each > row one by one. The iteration will then be in your service class and the > insert will be trivial like this one. > <insert id="insertAuthor" parameterType="domain.blog.Author"> > insert into Author (id,username,password,email,bio) > values (#{id},#{username},#{password},#{email},#{bio}) > </insert>
> Christian
> -----Message d'origine----- > De : mybati...@googlegroups.com <javascript:> [mailto:
> mybati...@googlegroups.com <javascript:>] De la part de Guy Rouillier > Envoyé : November-21-12 12:38 AM > À : mybati...@googlegroups.com <javascript:> > Objet : Re: ### Error updating database. Cause: > org.apache.ibatis.reflection.ReflectionException - iBatis
> On 11/20/2012 10:23 PM, PP wrote: > > Basically i want to the content of your Employee/Address tables as > > values to insert of Workplace table. My actual scenario is...i have > > one table at GUI which gets populated from different DB tables and > > also insert . I don have issue with select...but insert operation i am > > facing issue..it is like 1+N insert.
> Why can't you do this with a insert-select statement? I see that is what > you have in your original post, but you have all MyBatis parameter markers > in your SELECT statement, e.g., #{compRegNum}. Because you have those, you > are selecting all constant values. If you want to do that, you don't need > the SELECT at all; just put the MyBatis parameter markers into the values > clause for the insert.
> But from your description, what you really want to do is a simple insert > select, where the items in the select list are columns from the source > table.
> Sorry, this is all I can say unless you can clarify your scenario better. > If you have a bunch of rows in a GUI which need to get inserted into a > table, then iterate over those rows and invoke a simple insert statement > each iteration, inserting a single row; using MyBatis parameter markers for > the values clause in that insert statement.
> > On Wednesday, November 21, 2012 9:01:38 AM UTC+9, Guy wrote:
> > On 11/19/2012 8:11 PM, PP wrote: > > > Hi all, please suggest me alternate way to handle this...issue
> > > On Thursday, November 15, 2012 1:15:17 PM UTC+9, PP wrote:
> > > Hi All,
> > > When i run insert query through unit testing,i get below > > exception
> > > |org.apache.ibatis.exceptions.IbatisException: > > > ### Error updating database. Cause: > > org.apache.ibatis.reflection.ReflectionException:*There is no getter > > for property named 'empNumber' in 'class java.util.ArrayList'* > > > ### The error may involve > WorkplaceDetail.insertWorkplace-Inline > > > ### The error occurred while setting parameters > > > ### Cause: org.apache.ibatis.reflection.ReflectionException: > > There is no getter for property named 'empNumber' in 'class > > java.util.ArrayList' > > > at
> > The error is here - you are missing the "#" before the squiggle > > bracket. > > However, I'm not following what you are trying to accomplish with > > this > > select statement. Your select list is being filled with values from > > your > > parameter, i.e., constants.
I have 3 different tables* Workplace,Address,Employee* In Workplace table, *Address_Id *and *EmployeeId *are *foreign *keys.
In java side i have POJO
public class Workplace{ private string companyName; private List<Employees> employees; private Address address
}
Now in GUI, i have a table where values come from these DB tables. for example,
> *CompanyName , EmployeeName, Address > **Oracle, Guy c-102, New jersy*
These vales are displayed using multi joins in Select query. this is simple. *select companyName, employee.empName, address.address from workplace* * inner join on Employee where workplace.empId=employee.employeeId* * inner join on address where workplace.addressId=Address.addressId;*
But for inserting I am facing issue while using ibatis. *insert into workplace (cmpanyName,EmployeeId, addressId) values (#{companyName},#{Employee.EmployeeId},#{Address.addressId});* * * I guess now you have understood my scenerio. :)
On Wednesday, November 21, 2012 2:38:26 PM UTC+9, Guy wrote:
> On 11/20/2012 10:23 PM, PP wrote: > > Basically i want to the content of your Employee/Address tables as > > values to insert of Workplace table. My actual scenario is...i have > > one table at GUI which gets populated from different DB tables and also > > insert . I don have issue with select...but insert operation i am facing > > issue..it is like 1+N insert.
> Why can't you do this with a insert-select statement? I see that is > what you have in your original post, but you have all MyBatis parameter > markers in your SELECT statement, e.g., #{compRegNum}. Because you have > those, you are selecting all constant values. If you want to do that, > you don't need the SELECT at all; just put the MyBatis parameter markers > into the values clause for the insert.
> But from your description, what you really want to do is a simple insert > select, where the items in the select list are columns from the source > table.
> Sorry, this is all I can say unless you can clarify your scenario > better. If you have a bunch of rows in a GUI which need to get inserted > into a table, then iterate over those rows and invoke a simple insert > statement each iteration, inserting a single row; using MyBatis > parameter markers for the values clause in that insert statement.
> > On Wednesday, November 21, 2012 9:01:38 AM UTC+9, Guy wrote:
> > On 11/19/2012 8:11 PM, PP wrote: > > > Hi all, please suggest me alternate way to handle this...issue
> > > On Thursday, November 15, 2012 1:15:17 PM UTC+9, PP wrote:
> > > Hi All,
> > > When i run insert query through unit testing,i get below > > exception
> > > |org.apache.ibatis.exceptions.IbatisException: > > > ### Error updating database. Cause: > > org.apache.ibatis.reflection.ReflectionException:*There is no getter > > for property named 'empNumber' in 'class java.util.ArrayList'* > > > ### The error may involve > WorkplaceDetail.insertWorkplace-Inline > > > ### The error occurred while setting parameters > > > ### Cause: org.apache.ibatis.reflection.ReflectionException: > > There is no getter for property named 'empNumber' in 'class > > java.util.ArrayList' > > > at
> > The error is here - you are missing the "#" before the squiggle > > bracket. > > However, I'm not following what you are trying to accomplish with > > this > > select statement. Your select list is being filled with values from > > your > > parameter, i.e., constants.
> I have 3 different tables*Workplace,Address,Employee*
> In Workplace table, *Address_Id *and *EmployeeId *are *foreign *keys.
> In java side i have POJO
> public class Workplace{
> private string companyName;
> private List<Employees> employees;
> private Address address
> }
> Now in GUI, i have a table where values come from these DB tables. for
> example,
> *CompanyName , EmployeeName, Address
> **Oracle, Guy c-102, New jersy*
> These vales are displayed using multi joins in Select query. this is
> simple.
> *select companyName, employee.empName, address.address from workplace*
> * inner join on Employee where workplace.empId=employee.employeeId*
> * inner join on address where workplace.addressId=Address.addressId;*
> But for inserting I am facing issue while using ibatis.
> *insert into workplace (cmpanyName,EmployeeId, addressId) values
> (#{companyName},#{Employee.EmployeeId},#{Address.addressId});*
> *
> *
> I guess now you have understood my scenerio. :)
Yes, I think I do. Your GUI contains a table or grid; in that grid, you display data from a database, and also allow the end-user to enter data into new rows. If the user enters new rows, you are asking how to persist those new rows into the database using MyBatis. Correct?
If so, then in your application back end, iterate over the new table rows. For each new row, perform a simple insert as shown on pages 24-25 of the User's Guide.
On Saturday, November 24, 2012 3:20:59 PM UTC+9, Guy wrote:
> On 11/22/2012 8:48 PM, PP wrote: > > I have 3 different tables*Workplace,Address,Employee* > > In Workplace table, *Address_Id *and *EmployeeId *are *foreign *keys.
> > Now in GUI, i have a table where values come from these DB tables. for > > example,
> > *CompanyName , EmployeeName, Address > > **Oracle, Guy c-102, New jersy*
> > These vales are displayed using multi joins in Select query. this is > > simple. > > *select companyName, employee.empName, address.address from workplace* > > * inner join on Employee where workplace.empId=employee.employeeId* > > * inner join on address where workplace.addressId=Address.addressId;*
> > But for inserting I am facing issue while using ibatis. > > *insert into workplace (cmpanyName,EmployeeId, addressId) values > > (#{companyName},#{Employee.EmployeeId},#{Address.addressId});* > > * > > * > > I guess now you have understood my scenerio. :)
> Yes, I think I do. Your GUI contains a table or grid; in that grid, you > display data from a database, and also allow the end-user to enter data > into new rows. If the user enters new rows, you are asking how to > persist those new rows into the database using MyBatis. Correct?
> If so, then in your application back end, iterate over the new table > rows. For each new row, perform a simple insert as shown on pages 24-25 > of the User's Guide.
> > Now in GUI, i have a table where values come from these DB
> tables. for
> > example,
> > *CompanyName , EmployeeName, Address
> > **Oracle, Guy c-102, New
> jersy*
> > These vales are displayed using multi joins in Select query. this is
> > simple.
> > *select companyName, employee.empName, address.address from
> workplace*
> > * inner join on Employee where workplace.empId=employee.employeeId*
> > * inner join on address where
> workplace.addressId=Address.addressId;*
> > But for inserting I am facing issue while using ibatis.
> > *insert into workplace (cmpanyName,EmployeeId, addressId) values
> > (#{companyName},#{Employee.EmployeeId},#{Address.addressId});*
> > *
> > *
> > I guess now you have understood my scenerio. :)
> Yes, I think I do. Your GUI contains a table or grid; in that grid,
> you
> display data from a database, and also allow the end-user to enter data
> into new rows. If the user enters new rows, you are asking how to
> persist those new rows into the database using MyBatis. Correct?
> If so, then in your application back end, iterate over the new table
> rows. For each new row, perform a simple insert as shown on pages
> 24-25
> of the User's Guide.
> > > Now in GUI, i have a table where values come from these DB > > tables. for > > > example,
> > > *CompanyName , EmployeeName, Address > > > **Oracle, Guy c-102, New > > jersy*
> > > These vales are displayed using multi joins in Select query. this > is > > > simple. > > > *select companyName, employee.empName, address.address from > > workplace* > > > * inner join on Employee where > workplace.empId=employee.employeeId* > > > * inner join on address where > > workplace.addressId=Address.addressId;*
> > > But for inserting I am facing issue while using ibatis. > > > *insert into workplace (cmpanyName,EmployeeId, addressId) values > > > (#{companyName},#{Employee.EmployeeId},#{Address.addressId});* > > > * > > > * > > > I guess now you have understood my scenerio. :)
> > Yes, I think I do. Your GUI contains a table or grid; in that grid, > > you > > display data from a database, and also allow the end-user to enter > data > > into new rows. If the user enters new rows, you are asking how to > > persist those new rows into the database using MyBatis. Correct?
> > If so, then in your application back end, iterate over the new table > > rows. For each new row, perform a simple insert as shown on pages > > 24-25 > > of the User's Guide.
Well, I think you get the idea. Iterate over your collection in your code, and use the insert statement one at a time. The values passed to the insert statement need to be scalar values.
> > > Now in GUI, i have a table where values come from these DB
> > tables. for
> > > example,
> > > *CompanyName , EmployeeName, Address
> > > **Oracle, Guy
> c-102, New
> > jersy*
> > > These vales are displayed using multi joins in Select
> query. this is
> > > simple.
> > > *select companyName, employee.empName, address.address from
> > workplace*
> > > * inner join on Employee where
> workplace.empId=employee.employeeId*
> > > * inner join on address where
> > workplace.addressId=Address.addressId;*
> > > But for inserting I am facing issue while using ibatis.
> > > *insert into workplace (cmpanyName,EmployeeId, addressId)
> values
> (#{companyName},#{Employee.EmployeeId},#{Address.addressId});*
> > > *
> > > *
> > > I guess now you have understood my scenerio. :)
> > Yes, I think I do. Your GUI contains a table or grid; in
> that grid,
> > you
> > display data from a database, and also allow the end-user to
> enter data
> > into new rows. If the user enters new rows, you are asking
> how to
> > persist those new rows into the database using MyBatis.
> Correct?
> > If so, then in your application back end, iterate over the
> new table
> > rows. For each new row, perform a simple insert as shown on
> pages
> > 24-25
> > of the User's Guide.
> Well, I think you get the idea. Iterate over your collection in your > code, and use the insert statement one at a time. The values passed to > the insert statement need to be scalar values.
> > But i don't think making Employee.employeeId will work, since it is > > arraylist. And will throw any error of "can't employeeId in > workplace.java"
> > > > These vales are displayed using multi joins in Select > > query. this is > > > > simple. > > > > *select companyName, employee.empName, address.address > from > > > workplace* > > > > * inner join on Employee where > > workplace.empId=employee.employeeId* > > > > * inner join on address where > > > workplace.addressId=Address.addressId;*
> > > > But for inserting I am facing issue while using ibatis. > > > > *insert into workplace (cmpanyName,EmployeeId, addressId) > > values
> > (#{companyName},#{Employee.EmployeeId},#{Address.addressId});* > > > > * > > > > * > > > > I guess now you have understood my scenerio. :)
> > > Yes, I think I do. Your GUI contains a table or grid; in > > that grid, > > > you > > > display data from a database, and also allow the end-user to > > enter data > > > into new rows. If the user enters new rows, you are asking > > how to > > > persist those new rows into the database using MyBatis. > > Correct?
> > > If so, then in your application back end, iterate over the > > new table > > > rows. For each new row, perform a simple insert as shown on > > pages > > > 24-25 > > > of the User's Guide.
Why are you invoking setEmployee(list); repeatedly within this loop? And what is the point of setting a list of employees in workplaceDetail? You won't be able to persist a list; you have to persist each member of the list independently.
> But still i am not able to insert after iterating Employee, but i am
> able to insert other values of workplace. Please help me.