views:

14

answers:

0

Hi

Could I use a non-persistent domain object as a command object in spring mvc and have an instance of a persistent(made persistent using @Entity annotation in the domain class) object in it and have its (persistent object) data made persistant in a database?

I am using AbstractWizardFormController for my application and it shows the data of both the persistent and non-persistent domain objects in all the jsp pages in the wizard but when it comes processFinish(..) method to finish the wizard, where i am trying to persist on the data of the properties of the persistent domain object to the database, it gives me a java.lang.NullPointerException.

The situation is like this:

Non-persistent domain object

public class A {
    private int x;
    private B b; // B is a persistent domain object (made persistent using @Entity annonation)

    setters and getters...
    ...
}

Persistent domain object

@Entity
public class B {

    @Id
    @GeneratedValue
    private Long id;
    private List<C> c; // c is some other persistent domain object
    ...

    setters and getters...
    ...

}

The thing is that i need the "x" variable in the non-persistent object (that I want to use as a command object) for some data to be used on the jsp pages in the wizard but not to have it persisted in the database.

I've posted the complete code of the application I've been trying with all the files being used in it at javaranch as well, where you could see the line numbers in code as well. Here is the link to follow the complete code there, http://www.coderanch.com/t/507667/Spring/AbstractWizardFormController-java-lang-NullPointerException-at

Could someone help me with query mentioned above? Thanks