Product Information > JADE .NET Developer’s Reference > Chapter 7 - Developing Applications in .NET to Use JADE Classes > Creating Objects

Creating Objects

You can use the new operator to create a persistent or transient instance of an exposed JADE class, together with the no-parameters constructor for the class or the constructor with a ClassPersistence enumeration value of Persistent or Transient.

The following statements are equivalent.

Agent agent = new Agent();
Agent agent = new Agent(ClassPersistence.Persistent);

Alternatively, you can use the CreateInstance method of the JoobContext class.

JoobContext context = JoobContext.CurrentContext;
Agent agent = context.CreateInstance<Agent>(ClassPersistence.Persistent);

Transient objects belong to the process that created them and are not accessible by any other process. The transient objects for a process are retained until explicitly deleted or when the process is disposed of (typically when the .NET application terminates).

Because the transient objects for each process are retained, they are available the next time a JoobContext instance is created and associated with that process. However, the associated process may be any of the processes in the pool.

To create, modify, or delete a persistent object, you must be in transaction state. For details, see "Transactions", later in this chapter.