cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Carlos Chávez <ccha...@agssa.net>
Subject RE: using OJB for multiple insert
Date Wed, 17 Sep 2008 12:33:40 GMT
Hi.

Please post the stacktrace.

Cheers.
Carlos Chávez.

Мария Григорьева Escribio :-)
> Hello, it doesn't work...
> It's strange, but depts are still null...
> Maybe I should change smth in bean:
>
> package org.apache.cocoon.ojb.mysamples;
>
> import java.io.Serializable;
>
> public class Dept implements Serializable {
>
> 	private int deptno;
> 	private String dname;
> 	private String loc;
> 	public int getDeptno() {
> 		return deptno;
> 	}
> 	public void setDeptno(int deptno) {
> 		this.deptno = deptno;
> 	}
> 	public String getDname() {
> 		return dname;
> 	}
> 	public void setDname(String dname) {
> 		this.dname = dname;
> 	}
> 	public String getLoc() {
> 		return loc;
> 	}
> 	public void setLoc(String loc) {
> 		this.loc = loc;
> 	}
>
>
> }
>
> -----Original Message-----
> From: Carlos Chávez [mailto:cchavez@agssa.net]
> Sent: Wednesday, September 17, 2008 9:08 AM
> To: users@cocoon.apache.org
> Subject: Re: using OJB for multiple insert
>
> Мария Григорьева Escribio :-)
>> Hello!
>>
>> I'm using OJB!!!
>>
>> The problem is:
>>
>> I want to make a test on insert.
>>
>>
>>
>> Here is my sample-function:
>>
>>
>>
>> public void doInsertTest() {
>>
>>                 Dept[] depts = null;
>>
>>                 for (int i = 0; i < 5; i++) {
>>
>>                                depts[i].setDeptno(i);
>>
>>                                depts[i].setDname("Hello");
>>
>>                 }
>>
>>                 Object deptObj = depts;
>>
>>                 for (int i = 0; i < depts.length; i++) {
>>
>>             Dept dept = (Dept) deptObj;
>>
>>             broker.store(dept);
>>
>>         }
> Hi There.
>
> try: Dept[] depts = new Dept[5];
>
> or
>
> for (int i=1; i<=5; i++) {
>   Dept dept = new Dept();
>
>   dept.setDeptno(i);
>   dept.setDname("Hello - " + i);
>   broker.store(dept);
> }
>
> something like that.
>
> Cheers.
> Carlos Chávez.
>
>>
>>         long time = System.currentTimeMillis();
>>
>>                 sendPage("screens/test-template", new
>> VarMap().add("test",
>> time));
>>
>>     }
>>
>>
>>
>> But I've got java.lang.NullPointerException:
>>
>>
>>
>> Depts are staying null!
>>
>>
>>
>>
>>
>> What should I do?
>>
>> How to pass an array to this function?
>>
>>
>>
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message