[appengine-java] Re: is not persistable

2009-09-08 Thread Jason (Google)
Make sure to close your PersistenceManager instance in getCategories().

Are you seeing the original error or a different stack trace?

- Jason

On Sun, Sep 6, 2009 at 7:06 AM, Bob L.  wrote:

>
> Oh mine! It occurred again. JDO looks quite fragile.
> Is there any wrong with following code?
>
> @PersistenceCapable(identityType = IdentityType.APPLICATION)
> public class Category {
>@PrimaryKey
>@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
>private Long id;
>@Persistent
>private String name;
>
>public Category() {
>}
>
>public Category(String name) {
>this.name = name;
>}
>
>public Long getId() {
>return id;
>}
>
>public String getName() {
>return name;
>}
>
>public void setName(String name) {
>this.name = name;
>}
> }
>
> serverlet:
> ...
> @SuppressWarnings("unchecked")
>public List getCategories() {
>String query = "select from " + Category.class.getName();
>PersistenceManager pm = PMF.get().getPersistenceManager();
>try {
>return (List)
> pm.newQuery(query).execute();
>} catch (Exception ex) {
>}
>
>return null;
>}
>
>private void initializeCategories() {
>List categories = this.getCategories();
>if (categories == null || categories.isEmpty()) {
>categories = new ArrayList();
>Category category = new Category("Boys");
>categories.add(category);
>category = new Category("Girls");
>categories.add(category);
>PersistenceManager pm =
> PMF.get().getPersistenceManager();
>try {
>pm.makePersistentAll(categories);
>} finally {
>pm.close();
>}
>}
>}
> ...
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en
-~--~~~~--~~--~--~---



[appengine-java] Re: is not persistable

2009-09-06 Thread datanucleus

> Oh mine! It occurred again. JDO looks quite fragile.

Nothing fragile about the persistence process. You simply have to
define your classes as persistent and enhance them, and have the
enhanced ones in the CLASSPATH. Not hard
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en
-~--~~~~--~~--~--~---



[appengine-java] Re: is not persistable

2009-09-06 Thread Bob L.

Oh mine! It occurred again. JDO looks quite fragile.
Is there any wrong with following code?

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Category {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Long id;
@Persistent
private String name;

public Category() {
}

public Category(String name) {
this.name = name;
}

public Long getId() {
return id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}
}

serverlet:
...
@SuppressWarnings("unchecked")
public List getCategories() {
String query = "select from " + Category.class.getName();
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
return (List) pm.newQuery(query).execute();
} catch (Exception ex) {
}

return null;
}

private void initializeCategories() {
List categories = this.getCategories();
if (categories == null || categories.isEmpty()) {
categories = new ArrayList();
Category category = new Category("Boys");
categories.add(category);
category = new Category("Girls");
categories.add(category);
PersistenceManager pm = 
PMF.get().getPersistenceManager();
try {
pm.makePersistentAll(categories);
} finally {
pm.close();
}
}
}
...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en
-~--~~~~--~~--~--~---



[appengine-java] Re: is not persistable

2009-09-01 Thread Bob L.

What a shame! I forgot this line on the class: @PersistenceCapable
(identityType = IdentityType.APPLICATION)

Thx.

On Sep 1, 10:20 pm, "Bob L."  wrote:
> 1. It is in CLASSPATH as all classes are in the project.
> 2. I basically copied from the example, so it should not be a problem
> about annotations.
>
> I don't know how to check "hidden by an unenhanced version". Someone
> said I can find the clues in the debug-level logging, but how can I
> view them?
>
> On Sep 1, 4:14 am, datanucleus  wrote:
>
>
>
> > > The class "The class "x.Category" is not persistable. This means that
> > > it either hasnt been enhanced,
> > > or that the enhanced version of the file is not in the CLASSPATH (or is 
> > > hidden by an unenhanced version),
> > > or the Meta-Data/annotations for the class are not found.
>
> > And when you've checked those 3 things ... you can conclude that one
> > of them is the cause.- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en
-~--~~~~--~~--~--~---



[appengine-java] Re: is not persistable

2009-09-01 Thread Bob L.

1. It is in CLASSPATH as all classes are in the project.
2. I basically copied from the example, so it should not be a problem
about annotations.

I don't know how to check "hidden by an unenhanced version". Someone
said I can find the clues in the debug-level logging, but how can I
view them?

On Sep 1, 4:14 am, datanucleus  wrote:
> > The class "The class "x.Category" is not persistable. This means that
> > it either hasnt been enhanced,
> > or that the enhanced version of the file is not in the CLASSPATH (or is 
> > hidden by an unenhanced version),
> > or the Meta-Data/annotations for the class are not found.
>
> And when you've checked those 3 things ... you can conclude that one
> of them is the cause.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en
-~--~~~~--~~--~--~---



[appengine-java] Re: is not persistable

2009-08-31 Thread datanucleus

> The class "The class "x.Category" is not persistable. This means that
> it either hasnt been enhanced,
> or that the enhanced version of the file is not in the CLASSPATH (or is 
> hidden by an unenhanced version),
> or the Meta-Data/annotations for the class are not found.

And when you've checked those 3 things ... you can conclude that one
of them is the cause.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-java@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en
-~--~~~~--~~--~--~---