[appengine-java] Re: Accessing Google spreadsheet using Java

2010-11-17 Thread Vikas Hazrati
Hi,

We implemented the attachment solution using the combination of
Spreadhseet API and Document List API. The way we implemented the
solution is blogged here
http://thoughts.inphina.com/2010/11/17/mailing-google-docs-as-attachment-on-google-app-engine/

Regards | Vikas
www.inphina.com

On Nov 13, 6:35 pm, Vikas Hazrati  wrote:
> We are directly using thespreadsheetAPI to manage data within thespreadsheet, 
> that seems to work fine for us
>
> http://code.google.com/apis/spreadsheets/data/3.0/developers_guide.html
>
> Regards | Vikaswww.inphina.com
>
> On Nov 1, 3:55 pm, prakhil samar  wrote:
>
> > I have created a googlespreadsheetand I want to access its contents
> > using java. I have created the following code:
> > public static void main(String[] args) throws Exception{
>
> >         URL feedUrl = new URL("");
>
> >                 SpreadsheetService myService = new
> > SpreadsheetService("googleapps_spreadsheet");
> >                 myService.setUserCredentials("prakhil.purch...@gmail.com",
> > "purchase");
> >         SpreadsheetFeed resultFeed = myService.getFeed(feedUrl,
> > SpreadsheetFeed.class);
>
> >         System.out.println("YourSpreadsheet:");
> >         for(int i=0; i >                 SpreadsheetEntry entry = resultFeed.getEntries().get(i);
> >                 System.out.println("\t"+
> > entry.getTitle().getPlainText());
>
> >         }
> >     }
>
> > It not giving any results. Can somebody who has used googlespreadsheetwith 
> > java before, please suggest what is the mistake in
> > the code.
>
> > Thanks in advance.

-- 
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-j...@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: How to write a JPA unit test for GAE?

2010-11-14 Thread Vikas Hazrati
hi lucio,

I have added the requested information as an answer to your comment on
the blog post.

http://thoughts.inphina.com/2010/06/28/unit-testing-maven-based-jpa-application-on-gae/#comment-347

regards | Vikas
www.inphina.com

On Nov 15, 4:23 am, lp  wrote:
> hi vikas
>
> nice blog u have there. However i cant reproduce your results the unit
> test with spring.
> can u post your spring config to see what i have done wrong.
>
> thanks
>
> -lp
>
> On Nov 13, 3:58 pm, Vikas Hazrati  wrote:
>
> > You could get more information on the way we set up our testing infra
> > here
>
> >http://thoughts.inphina.com/2010/06/28/unit-testing-maven-based-jpa-a...
>
> > Regards | Vikaswww.inphina.com

-- 
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-j...@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] How to send spreadsheet as an attachment on Google App Engine?

2010-11-14 Thread Vikas Hazrati
I have an application which is deployed on the Google App Engine. This
application also works with the Google spreadsheet API to update a
couple of spreadsheets.

Once the user is done with changing the spreadsheet data, I want to
email the resultant spreadsheet (not the link) to the manager.

Is there a way to attach the spreadsheet as an attachment ?

Since the app engine supports multi-part for attachment,
http://code.google.com/appengine/docs/java/mail/usingjavamail.html#Multi_Part_Messages
I guess I would need to get the content of the spreadsheet back as a
byte []. How can I do that?

Is there any other way to approach this problem?

Regards | Vikas
www.inphina.com

-- 
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-j...@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: Accessing Google spreadsheet using Java

2010-11-13 Thread Vikas Hazrati
We are directly using the spreadsheet API to manage data within the
spreadsheet, that seems to work fine for us

http://code.google.com/apis/spreadsheets/data/3.0/developers_guide.html

Regards | Vikas
www.inphina.com

On Nov 1, 3:55 pm, prakhil samar  wrote:
> I have created a googlespreadsheetand I want to access its contents
> using java. I have created the following code:
> public static void main(String[] args) throws Exception{
>
>         URL feedUrl = new URL("");
>
>                 SpreadsheetService myService = new
> SpreadsheetService("googleapps_spreadsheet");
>                 myService.setUserCredentials("prakhil.purch...@gmail.com",
> "purchase");
>         SpreadsheetFeed resultFeed = myService.getFeed(feedUrl,
> SpreadsheetFeed.class);
>
>         System.out.println("YourSpreadsheet:");
>         for(int i=0; i                 SpreadsheetEntry entry = resultFeed.getEntries().get(i);
>                 System.out.println("\t"+
> entry.getTitle().getPlainText());
>
>         }
>     }
>
> It not giving any results. Can somebody who has used googlespreadsheetwith 
> java before, please suggest what is the mistake in
> the code.
>
> Thanks in advance.

-- 
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-j...@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: Problems pointing my GoDaddy domain to App Engine (no other posts have been able to help!)

2010-11-12 Thread Vikas Hazrati
Sometimes it just takes time for redirection to happen as it needs to
be propagated across servers. We have mapped several domains from
GoDaddy to the app engine and it just works.

Regards | Viaks
www.inphina.com

On Nov 9, 8:59 pm, Kevin M  wrote:
> So I have a domain hosted on GoDaddy.com and I just set up Google App
> Engine and Google Apps. I registered my new domain with Google Apps so
> that I can see it in my dashboard and I believe I did what I needed to
> do to verify I'm the owner of the domain. I added the CNAME entry in
> GoDaddy for www to point to ghs.google.com and removed all others. I
> set up the MX records I saw in another post so at least my email is
> going where I expect it to. But, my new URL is not going to my google
> app engine application for some reason. Do I need to change the Name
> Servers from GoDaddy name servers to Google name servers? Do I need
> A(Host) entries? I'm confused. Please help!

-- 
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-j...@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: How to write a JPA unit test for GAE?

2010-11-12 Thread Vikas Hazrati
You could get more information on the way we set up our testing infra
here

http://thoughts.inphina.com/2010/06/28/unit-testing-maven-based-jpa-application-on-gae/

Regards | Vikas
www.inphina.com

On Nov 10, 2:37 pm, lp  wrote:
> hi all,
>
> i have been attempting to convert my existing JPA code over to GAE.
>
> All is working so far except for the unit tests.
>
> i read
> code.google.com/appengine/docs/java/tools/localunittesting.html
>
> but it doesnt describe how to get an entityManager involved in usefull
> unit tests.
>
> so this is my test. please advise how to achieve the functionality in
> this test.
>
> @Test
> public void findFriendsSimple() {
>
> PositionUser user1 = new PositionUser();
> user1.setFirstName("john");
> user1.setLastName("smith");
>
> PositionUser user2 = new PositionUser();
> user2.setFirstName("mary");
> user2.setLastName("smith");
>
> PositionUser user3 = new PositionUser();
> user3.setFirstName("barney");
> user3.setLastName("smith");
>
> em.persist(user2);
> em.persist(user3);
> //em.flush(); <--- can use flush for non transaction test
>
> user1.getFriends().add(user2.getKey());
> user1.getFriends().add(user3.getKey());
>
> em.persist(user1);
> //em.flush(); <--- can use flush for non transaction test
>
> Query query = em.createNamedQuery(PositionUser.FIND_FRIENDS);
> query.setParameter("userKey", user1.getKey());
> List resultList = query.getResultList();
> assertEquals( 2, resultList.size() );
>
> }
>
> the assert is triggered
> java.lang.AssertionError: expected:<2> but was:<0>
>
> this is because the entitymanager wont detect the persisted entities
> that arent in a transaction.
>
> ok no problem, i will add transactions.
>
> But when i do it complains that i am adding multiple groups in a single
> transaction.
>
> So besides the simple gae sample unit test, how are others writting
> useful unit tests in gae?
>
> any help is most appreciated
>
> -lp

-- 
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-j...@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: GAE or EC2

2010-11-08 Thread Vikas Hazrati
You might also want to check out a detailed comparison on technical
aspects here

http://thoughts.inphina.com/2010/11/01/comparing-google-app-engine-and-amazon-ec2-on-technology/

Regards | Vikas

On Nov 9, 9:32 am, Didier Durand  wrote:
> Hi JY,
>
> I have used both: for a small company aiming at big applications, I
> would definitely go GAE because it's PaaS: you don't have to deal with
> the infrastructure which can become quite time consuming when your
> application gets big if on EC2 (you have to update/patch your images,
> take care of your scaling, etc.). It's probably not what you want to
> spend time on at start with limited resource.
>
> On the other side, GAE has of course limitations / restrictions: Java-
> only, datastore specific architecture, etc.
>
> To reassure you, (a) the code of GAE is open source (did not check if
> 100%) and (b) some people are trying to replicate the system in an
> independent fashion to provide alternatives: check out the AppScale
> project 
> athttp://googleappengine.blogspot.com/2010/10/research-project-appscale...
>
> regards
> didier
>
> On Nov 9, 2:59 am, JY  wrote:
>
> > I want to ask fellow GAE users whether you think GAE is good choice to
> > build real business on?
> > I have used GAE for some personal projects, and right now help a
> > friend on a tiny start up (but with big dream). The project is related
> > to social network - I am thinking of two options:
> > 1, GAE
> > The benefits are obvious. However, it is also locking you inyou
> > don't have much control over it. If you are unhappy later, you will
> > have to redo the persistence layer and migrate data etc.
> > 2, EC2
> > You have much more control, and if the start-up gets funding, it is
> > easy to migrate to dedicated hosting or even its own data center. The
> > down side is developer (me, and only me) will have to spend quite some
> > time to take care of the infrastructure (although I like this kind of
> > work...)
>
> > I think my biggest concern of GAE is over the quality of service, and
> > the data-store - if I go EC2, I probably will use a NoSQL solution
> > like MogoDb, or Cassandra. The development efforts might be similar -
> > all products are sort of young, hot, and limited.
>
> > Thanks.
>
> > JY

-- 
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-j...@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: too many 500 Errors

2010-11-01 Thread Vikas Hazrati
It seems that there is some serious datastore issue. The status on the
http://code.google.com/status/appengine is also elevated and both Java
and Python services are affected.

Regards | Vikas
www.inphina.com
Sarath wrote:
> My application is seeing a lot of these errors recently.
>
> Request was aborted after waiting too long to attempt to service your
> request. This may happen sporadically when the App Engine serving
> cluster is under unexpectedly high or uneven load. If you see this
> message frequently, please contact the App Engine team.
>
> It was working fine a lot of days. What do we do? I put this site up
> on 1.3.7 do I have to redeploy with 1.3.8?
>
> -Sarath

-- 
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-j...@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: Disappointment about JPA relationships :(

2010-10-24 Thread Vikas Hazrati
Hi Matthieu,

You are right, you need some conditioning and then you need to work
around the limitations of working with relationships around JPA. Then
finally you tend to realize more and more that may be you are better
off with unowned relationships

Here are the issues that we faced and tried to resolve http://wp.me/pNh6u-6b

Regards | Vikas
www.inphina.com

On Oct 23, 9:01 pm, Matthieu Bertin  wrote:
> Hello,
>
> I'm just here because i feel i need to rant a little. I came here
> expecting way too much. I'm of course blaming me for being way too
> optimistic but i also believe ranting against google is somehow
> justifiable, and i'll explain why.
>
> I've started porting an application on Google App engine and i'm now
> sick of discovering exceptions like :
>
> - Detected attempt to establish PictureThread(28) as the parent of
> Picture(27) but the entity identified by Picture(27) has already been
> persisted without a parent. A parent cannot be established or changed
> once an object has been persisted
> - cannot operate on two differents types of entities in the same
> request/transaction'. Your documentation has headed me in the wrong
> direction; all you mention is 'unowned relationships' and 'many-to-many
> relationships' are not supported.
> Please fix that. Give us the real limitations on the documentation!
> There is no mention of "one to one" limitations or 'handling multiple
> entities in same transaction' limitations anywhere.
>
> It would totally be understandable not to mention theses limitations
> when JDBC APIs were created, but nowadays, when you mention 'JPA', this
> kind of limitations HAVE to be mentionned.

-- 
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-j...@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] Recommendations for a "Greenfield project"

2010-10-12 Thread Vikas Hazrati
We recently helped an organization move their pretty successful
standalone enterprise timesheet product to the app engine and offer it
as a SaaS application. The project used Spring, Wicket,
Hibernate(which we converted to JPA). However we had to face many
obstacles on the way. You can read about ALL our logs here
http://thoughts.inphina.com/tag/GAE/

The problems that I would like to highlight with Spring was the slow
startup time and the time killing our application on each cold start
because the beans were brought back to life again. Several times we
breached the 30 s barrier. With wicket we faced serialization issues
and with JPA we have a lot of blogs on how we made our way around
them.

You can access the application here http://www.bookmyhours.com/demo.jsp

OK, the main question -  Now we are getting into a greenfield project,
we do not have any baggage of frameworks used in the past. The project
is a B2C portal, mostly reads, form submissions and results, payment
gateway etc. What would you recommend as the application stack for
such a development?

We are contemplating between

GWT + Spring Roo + Objectify
GWT + slim3 + Objectify / Twig
GWT + Guice + Objectify / Twig
Non GWT + Any of above options
Any other options?

What would you propose for new development and what should be our
deciding factors?

Regards | Vikas

-- 
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-j...@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: Downloading application logs from app engine

2010-10-02 Thread Vikas Hazrati
I guess copy paste is the only way out ;)

On Sep 30, 5:45 pm, Vikas Hazrati  wrote:
> I am trying to download the application logs from the app engine but
> with the command that I am using
>
> appcfg.sh request_logs  0051.txt
>
> I am able to get the app engine logs and not the ones that I get when
> i expand the logs. So in a nutshell
>
> instead of "just" this as a part of download
>
> 09-30 04:58AM 40.954 / 302 24240ms 22236cpu_ms 1080api_cpu_ms 0kb
> Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.3 (KHTML, like
> Gecko) Chrome/6.0.472.63 Safari/534.3,gzip(gfe)
>
> I would like to get the following logs which i see when i expand the
> above log in the admin console
>
> 09-30 04:58AM 40.954 / 302 24240ms 22236cpu_ms 1080api_cpu_ms 0kb
> Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.3 (KHTML, like
> Gecko) Chrome/6.0.472.63 Safari/534.3,gzip(gfe)
>
> [myappid/0-0-5-1.345167134118388057].: 2010-09-30 11:58:45,996
> INFO  com.myapp.util.admin.LogLoadingRequest - GAE ALERT !!
> Loading request occuring.
>
> I 09-30 04:58AM 47.802 javax.servlet.ServletContext log: Initializing
> Spring root WebApplicationContext
>
> Regards | Vikas

-- 
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-j...@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] Downloading application logs from app engine

2010-09-30 Thread Vikas Hazrati
I am trying to download the application logs from the app engine but
with the command that I am using

appcfg.sh request_logs  0051.txt

I am able to get the app engine logs and not the ones that I get when
i expand the logs. So in a nutshell

instead of "just" this as a part of download

09-30 04:58AM 40.954 / 302 24240ms 22236cpu_ms 1080api_cpu_ms 0kb
Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.3 (KHTML, like
Gecko) Chrome/6.0.472.63 Safari/534.3,gzip(gfe)

I would like to get the following logs which i see when i expand the
above log in the admin console

09-30 04:58AM 40.954 / 302 24240ms 22236cpu_ms 1080api_cpu_ms 0kb
Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.3 (KHTML, like
Gecko) Chrome/6.0.472.63 Safari/534.3,gzip(gfe)

[myappid/0-0-5-1.345167134118388057].: 2010-09-30 11:58:45,996
INFO  com.myapp.util.admin.LogLoadingRequest - GAE ALERT !!
Loading request occuring.

I 09-30 04:58AM 47.802 javax.servlet.ServletContext log: Initializing
Spring root WebApplicationContext

Regards | Vikas

-- 
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-j...@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: Trouble unit testing JPA data access objects.

2010-09-29 Thread Vikas Hazrati
I can understand the frustration. For GAE we have our transactions at
the dao level unless we know that it can be at the service level.
Since we are banking on the data becoming eventually consistent, we do
not have transaction related problems right now.
And, since they are at the dao level we do not get into the issue you
mentioned. Not sure if you can move your transactions a level down.

On Sep 28, 10:20 am, "David C. Hicks"  wrote:
>   I am most accustomed to defining my transactions at the service level,
> so that multiple DAO might be involved in a single transaction.  I do
> realize that the DataNucleus datastore has some peculiar behavior with
> regard to transactions.  I'm still learning the ins and outs, though.
>
> My test setup is essentially identical to what is posted in the blog
> entry you posted.  In one test, I create an entity, then I read it
> back.  Finally, I perform a query against one field which returns a
> collection containing the single entity, but when I call size() on the
> collection it throws the infamous "Object Manager has been closed"
> exception.  I can only assume that my test has no transaction wrapper,
> thus allowing the EntityManager to be closed very early in my test.  I
> just don't see how I can reasonably test anything if the Object Manager
> won't remain open long enough to verify the results.
>
> Dave
>
> On 09/28/2010 01:07 AM, Vikas Hazrati wrote:
>
>
>
> > Have you tried running the dao code in a transaction? Is your store
> > and find happening in different transactions? Also you should take a
> > note of "Unlike with most databases, queries and gets inside a
> > datastore transaction do not see the results of previous writes inside
> > that transaction. Specifically, if an entity is modified or deleted
> > within a transaction, a query or get will return the original version
> > of the entity as of the beginning of the transaction, or nothing if
> > the entity did not exist then." from the docs
> >http://code.google.com/appengine/docs/java/datastore/transactions.html
>
> > btw, for unit testing with the local datastore we have information on
> > our blog here
>
> >http://thoughts.inphina.com/2010/06/28/unit-testing-maven-based-jpa-a...
>
> > Regards | Vikas
>
> > On Sep 28, 4:35 am, "David C. Hicks"  wrote:
> >>    I have followed the instructions I found and set up the
> >> LocalServiceTestHelper to act as a datastore.  I can save an entity in
> >> the datastore and re-read it, but then I make a call to search for all
> >> entities that match a criteria.  The resulting List  collection
> >> throws an "Object Manager has been closed" exception as soon as I try to
> >> get the size().
>
> >> I understand that this is resolved in a real runtime environment by
> >> using the OpenEntityManagerInView filter, but in a testing environment
> >> the filter isn't in play.  I've been trying most of the day to figure
> >> out how to keep the object manager open through the life of a test, but
> >> damned if I can get it.  Anyone know of a good example somewhere?
>
> >> Thanks,
> >> Dave

-- 
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-j...@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: Namespace design issues

2010-09-27 Thread Vikas Hazrati
more details about the namespace behavior as we observed here

http://thoughts.inphina.com/2010/09/16/multi-tenancy-in-google-app-engine-scope-of-namespacemanager/


On Sep 24, 7:57 am, John Patterson  wrote:
> On 24 Sep 2010, at 02:55, Mouseclicker wrote:
>
> > API. The need to set and later reset a global setting is dangerous and
> > error-prone. Probably that's what Guillaume mentions with "The fear I
> > had was when seeing a static methods being used. I'm always afraid
> > when I see 'static' somewhere." Me too!
>
> The namespace is not global or static but stored per-thread so it must  
> be set for every request e.g. in a servlet Filter.  There is no  
> problem setting it for a single operation if it is reset in a finally  
> block.
>
> I personally like the way that the namespace API is completely  
> separated from other APIs.  In fact, I would prefer it if the memcache  
> API namespace did not override the namespace API namespace... that  
> caused a subtle bug the other day.
>
> It really is very important to be able to see all the stored data in  
> the datastore viewer without requiring the user to enter the  
> namespace.  Especially as the user could be billed for data they  
> cannot delete.

-- 
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-j...@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: EntityGroup restrictions on doing a Query outside of a txn

2010-09-27 Thread Vikas Hazrati
Somehow with the error message looks like both your queries are still
happening in the same transaction. Are you sure that the transaction
boundaries of both the methods are separate? To check this I would
separate the 2 out into 2 methods each having their own transaction
start and end or @Transactional if you are using Spring. Then with a
third method I would invoke the first, work on the results if anything
to do and then invoke the second and observe if I still get the same
error.
You could also try to run the first one without a transaction since it
is a fetch and if it is suits your application to execute it without
the tx.

Regards | Vikas
www.inphina.com

On Sep 27, 10:46 am, Yousuf Haider  wrote:
> First off I know that you can't operate on entities in different entity
> groups within the same transaction. My question is around a problem I am
> having where I am querying for certain entities (each in a different entity
> group) outside a txn and then I start a txn where I operate on an entity in
> a different entity group.
>
> In my model I have a root entity called User. So each instance of User will
> be in a different entity group.
>
> Here is what I am doing in pseudo-code:
>
> *Request comes in
>
> Create EntityManager
>
> Execute a JPA query using this EntityManager to retrieve the keys for all
> User entities satisfying a particular criteria (say we got UserKey1,
> UserKey2, UserKey3 back)
>
> Using EntityManager Start a txn
>   Retrieve User with id : UserKey4 (notice this is different from the ones
> we retrieved above)
>   Update this User object.
> Commit txn                         <<< Intermittently
> fails here
> Close EntityManager
>
> Return response
> *
>
> Notice here that the initial query is not part of the transaction that is
> subsequently created.* Inside that transaction only a single entity group is
> operated upon* (the Entity group for User object UserKey4).
>
> The first time the request goes in (after a server start) this code
> intermittently fails. Every subsequent request fails pretty consistently.
>
> The exception occurs at the commit with the infamous: "can't operate on
> multiple entity groups" exception. The 2 entities listed in the exception
> are the following:
> 1. the UserKey4
> 2. One of the User objects whose keys were returned in the initial query.
>
> This is really weird since within the txn I am operating on a single entity
> group. If my understanding is correct I should be able to do this.
>
> The only rational reason why this is happening might be that even querying
> for objects outside a txn and any subsequent txn should deal with entities
> in the same entity group. Is that the case or am I missing something here ?
>
> I have not been able to find a definite answer to this in the documentation
> so thought I'd try the mailing list.
>
> Thanks
> Yousuf

-- 
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-j...@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: Trouble unit testing JPA data access objects.

2010-09-27 Thread Vikas Hazrati
Have you tried running the dao code in a transaction? Is your store
and find happening in different transactions? Also you should take a
note of "Unlike with most databases, queries and gets inside a
datastore transaction do not see the results of previous writes inside
that transaction. Specifically, if an entity is modified or deleted
within a transaction, a query or get will return the original version
of the entity as of the beginning of the transaction, or nothing if
the entity did not exist then." from the docs
http://code.google.com/appengine/docs/java/datastore/transactions.html

btw, for unit testing with the local datastore we have information on
our blog here

http://thoughts.inphina.com/2010/06/28/unit-testing-maven-based-jpa-application-on-gae/

Regards | Vikas

On Sep 28, 4:35 am, "David C. Hicks"  wrote:
>   I have followed the instructions I found and set up the
> LocalServiceTestHelper to act as a datastore.  I can save an entity in
> the datastore and re-read it, but then I make a call to search for all
> entities that match a criteria.  The resulting List collection
> throws an "Object Manager has been closed" exception as soon as I try to
> get the size().
>
> I understand that this is resolved in a real runtime environment by
> using the OpenEntityManagerInView filter, but in a testing environment
> the filter isn't in play.  I've been trying most of the day to figure
> out how to keep the object manager open through the life of a test, but
> damned if I can get it.  Anyone know of a good example somewhere?
>
> Thanks,
> Dave

-- 
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-j...@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] Does BulkLoader consider relationships?

2010-09-17 Thread Vikas Hazrati
Hi,

There are several entities which have 1:n relationship in our SaaS
application. For the sake of simplicity and keeping the domain simple,
I tried the same concept with a small application but still found that
the configuration file formed with the BulkLoader did not respect
relationships.

For example,
I have 2 entities User and UserDepartment. They are related to each
other with a n:1 relationship.

@Entity
public class User extends DomainObject {
...
@ManyToOne(fetch = FetchType.EAGER)
private UserDepartment userDepartment;
...
}

and

@Entity
public class UserDepartment extends DomainObject
{
...
@OneToMany(mappedBy = "userDepartment", cascade = CascadeType.ALL,
fetch=FetchType.EAGER)
private Set users = new HashSet();
...
}

Now when I try to create a configuration file for my application with
a command like this

bulkloader.py --create_config --url=http://appname.appspot.com/
remote_api --application=appid --filename=generated_bulkloader.yaml

I see the following results in the generated_bulkloader.yaml

- kind: UserDepartment
  connector: csv
  connector_options:
encoding: utf-8
columns: from_header
  property_map:
- property: __key__
  external_name: key
  export_transform: transform.key_id_or_name_as_string

- property: name
  external_name: name
  # Type: String Stats: 16 properties of this type in this kind.


and

- kind: User
  connector: csv
  connector_options:
encoding: utf-8
columns: from_header
  property_map:
- property: __key__
  external_name: key
  export_transform: transform.key_id_or_name_as_string

- property: email
  external_name: email
  # Type: String Stats: 17 properties of this type in this kind.

- property: firstName
  external_name: firstName
  # Type: String Stats: 17 properties of this type in this kind.

- property: lastName
  external_name: lastName
  # Type: String Stats: 17 properties of this type in this kind.

- property: password
  external_name: password
  # Type: String Stats: 17 properties of this type in this kind.

- property: salt
  external_name: salt
  # Type: Integer Stats: 17 properties of this type in this kind.
  import_transform: transform.none_if_empty(int)

Hence there is no mention of either entity in either kind. Am I
missing something? Is there something that i can add to the generated
yaml file to fetch the relationships.

Regards | Vikas
www.inphina.com

-- 
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-j...@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] What is the scope for NamespaceManager?

2010-09-15 Thread Vikas Hazrati
We are building a multi-tenant application and want to use the
NamespaceManager to distinguish between tenants on the basis of server-
name. So for example inphina.bookmyhours.com would be a different
tenant than te-con.bookmyhours.com

we are currently using NamespaceFilter with code similar to

if (NamespaceManager.get() == null) {
switch (strategy) {
case SERVER_NAME: {
logger.info("The namespace for the request is: 
" +
request.getServerName());
NamespaceManager.set(request.getServerName());
if(seedDataSetup.setSeedData()) {

adminAccountValidator.updateAdminPassword();
}
break;
}

What we observed is that we always fall into the condition of
NamespaceManager.get() == null and hence the code has to set
NamespaceManager.set(request.getServerName()); again. Is it possible
to retain this setting at a session level. For all our users logging
in from inphina.bookmyhours.com, they would remain to be within the
same tenant.

>From the current implementation, it looks like the NamespaceManager
has a request scope. Comments/Suggestions?

Regards | Vikas
www.inphina.com

-- 
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-j...@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] Spring AOP on App Engine?

2010-09-06 Thread Vikas Hazrati
Has anyone got spring aop working with GAE? I get the following issue
deploying aop on the app engine

Error creating bean with name 'entityManagerFactory': Post-processing
of the FactoryBean's object failed; nested exception is
java.lang.StackOverflowError
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:
480)
at
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory
$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)

As always the loca dev environment 1.3.7 does not give any issues and
all my aspects work fine there. I have a timesheet and financial app
which and I do not want to log the audit calls at all the places. I
have defined the relevant pointcuts and auditing should be done at
those points.

Any suggestions / solutions?

Regards | Vikas
www.inphina.com

-- 
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-j...@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: How we can read uncommitted data in same transaction.

2010-08-31 Thread Vikas Hazrati
That sounds right, the data only becomes available to you once you
have committed the tx. From the docs

"This consistent snapshot view also extends to reads after writes
inside transactions. Unlike with most databases, queries and gets
inside a datastore transaction do not see the results of previous
writes inside that transaction. Specifically, if an entity is modified
or deleted within a transaction, a query or get will return the
original version of the entity as of the beginning of the transaction,
or nothing if the entity did not exist then."

On Aug 31, 8:19 am, Didier Durand  wrote:
> Hi Subhash,
>
> To my knowledge you can't do it: 
> seehttp://code.google.com/appengine/articles/transaction_isolation.html
> for all details.
> didier
>
> On Aug 30, 9:15 am, Subhash  wrote:
>
>
>
> > Hi,
>
> > Now I am using GAE for my application datastore. Before it, I was
> > using MySQL for my application database. In MySQL, we can fetch
> > uncommitted data through same connection in same transaction.
>
> > 
> > For Example:
> > Connection con = getConnection(); // Auto commit false of connection
> > PrepareStatement statement = con.prepareStatement("Insert into
> > Test(Name, Age) values('John', 23)", Statement.RETURN_GENERATED_KEYS);
> > Object key = statement.executeUpdate();
> > ResultSet resultSet = preparedStatement.getGeneratedKeys();
> > key = resultSet.getObject(1);
> > statement = con.prepareStatement("Select * From Test Where Id=" +
> > key);
> > resultSet = statement.executeQuery();
> > ===
>
> > Through same connection, I am able to fetch uncommitted data like
> > above example.
>
> > But how I can fetch uncommitted entities(Just put in DatastoreService
> > not committed) in GAE.
>
> > Any help/suggestions are highly appreciated.
>
> > Subhash

-- 
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-j...@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] Weird NPE when trying to work with appstats

2010-08-31 Thread Vikas Hazrati
For performance tuning we wanted use appstats and since ours is a java
based application, we used the steps as mentioned

As soon as we hit http://localhost:8080/appstats
We get the following error

java.lang.NullPointerException
at java.io.Reader.(Reader.java:61)
at java.io.InputStreamReader.(InputStreamReader.java:80)
at
com.google.appengine.tools.appstats.TemplateTool.loadTemplateSource(TemplateTool.java:
115)
at com.google.appengine.tools.appstats.Renderer
$1.loadTemplateSource(Renderer.java:49)
at
com.google.appengine.tools.appstats.TemplateTool.getTemplate(TemplateTool.java:
142)
at
com.google.appengine.tools.appstats.TemplateTool.format(TemplateTool.java:
100)
at com.google.appengine.tools.appstats.Renderer
$1.format(Renderer.java:59)
at
com.google.appengine.tools.appstats.Renderer.renderSummaries(Renderer.java:
74)
at
com.google.appengine.tools.appstats.AppstatsServlet.doGet(AppstatsServlet.java:
140)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:693)

If you notice, this is not a ClassNotFoundException, so
AppstatsServlet is found and it encounters an issue somewhere. After
spending a good couple of hours we included the labs jar as a part of
the the application lib. (Notice the commented out scope)

com.google.appengine
appengine-api-labs
${gae.version}



After this change the appstats started working.

Looking at the labs jar, it also has the TaskQueue classes. Is
Appstats also an experimental feature like TaskQueue?

When we uploaded our application to the App Engine platform, we got
the ClassNotFoundException for
com.google.appengine.tools.appstats.AppstatsFilter, which shows that
the class needs to be bundled with the application.
On the local environment, with 1.3.5, 1.3.6 and 1.3.7 we get the NPE
as mentioned above.

What is the right strategy? Do we need to bundle the labs with the
jars with the project? Why doesn't the local environment fail with
CNFE?

-- 
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-j...@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] Weird NPE when trying to work with appstats

2010-08-31 Thread Vikas Hazrati
For performance tuning we wanted use appstats and since ours is a java
based application, we used the steps as mentioned

As soon as we hit http://localhost:8080/appstats
We get the following error

java.lang.NullPointerException
at java.io.Reader.(Reader.java:61)
at java.io.InputStreamReader.(InputStreamReader.java:80)
at
com.google.appengine.tools.appstats.TemplateTool.loadTemplateSource(TemplateTool.java:
115)
at com.google.appengine.tools.appstats.Renderer
$1.loadTemplateSource(Renderer.java:49)
at
com.google.appengine.tools.appstats.TemplateTool.getTemplate(TemplateTool.java:
142)
at
com.google.appengine.tools.appstats.TemplateTool.format(TemplateTool.java:
100)
at com.google.appengine.tools.appstats.Renderer
$1.format(Renderer.java:59)
at
com.google.appengine.tools.appstats.Renderer.renderSummaries(Renderer.java:
74)
at
com.google.appengine.tools.appstats.AppstatsServlet.doGet(AppstatsServlet.java:
140)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:693)

If you notice, this is not a ClassNotFoundException, so
AppstatsServlet is found and it encounters an issue somewhere. After
spending a good couple of hours we included the labs jar as a part of
the the application lib. (Notice the commented out scope)

com.google.appengine
appengine-api-labs
${gae.version}



After this change the appstats started working.

Looking at the labs jar, it also has the TaskQueue classes. Is
Appstats also an experimental feature like TaskQueue?

When we uploaded our application to the App Engine platform, we got
the ClassNotFoundException for
com.google.appengine.tools.appstats.AppstatsFilter, which shows that
the class needs to be bundled with the application.
On the local environment, with 1.3.5, 1.3.6 and 1.3.7 we get the NPE
as mentioned above.

What is the right strategy? Do we need to bundle the labs with the
jars with the project? Why doesn't the local environment fail with
CNFE?

-- 
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-j...@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: Alternate for Like Clause

2010-08-10 Thread Vikas Hazrati
LIKE works in app engine though with a few minor constraints
here is one of our named queries

@NamedQuery(name = "User.findAllByUserFirstNamePattern", query =
"SELECT user "
+ "FROM User as user WHERE upperFirstName like 
:pattern " + "ORDER
BY upperFirstName"),

Regards | Vikas
www.inphina.com
www.thoughts.inphina.com

On Aug 10, 1:34 am, "Ikai L (Google)"  wrote:
> You can do a startswith query by using the "greater than" filter, but no,
> you cannot do substring match without iterating over entity properties in
> memory.
>
>
>
>
>
> On Mon, Aug 9, 2010 at 6:51 AM, MANISH DHIMAN  wrote:
> > Hi Friends
> > Is there any alternative  for LIKE clause in java.
>
> > --
> > 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-j...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > google-appengine-java+unsubscr...@googlegroups.com > unsubscr...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-appengine-java?hl=en.
>
> --
> Ikai Lan
> Developer Programs Engineer, Google App Engine
> Blog:http://googleappengine.blogspot.com
> Twitter:http://twitter.com/app_engine
> Reddit:http://www.reddit.com/r/appengine

-- 
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-j...@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: Changing the Parent of a child entity

2010-08-03 Thread Vikas Hazrati
I guess that makes sense and your example is dot on. I was wondering
are there real life applications on GAE where people are using JDO/JPA
relationships. The more the problems that I face with relationships
and the more I read about it, it seems that unowned is the way to go.

Thanks,
Vikas

On Aug 4, 12:53 am, Frederik Pfisterer  wrote:
> There are many Use Cases where it makes sense to keep relationships or
> you at least want to leverage the power of entity groups even with
> JDO. The school-of-thought is a bit different than in other
> environments though. While JDO parent to child access is comfortable
> it makes not the best use of GAE's massive scalability and performance
> advantages. One example:
>
> Say you have a user and all his comments are children in his entity
> group. Now in an old school way you would check how many there are is
> user.getComments().size() ... well that works but would have to load
> the entire array from the store. The new school way of doing this
> would be running a query filtered on keys that is an order of
> magnitude 
> faster:http://code.google.com/intl/de-DE/appengine/docs/java/datastore/queri...
> You can always retrieve the parent object (user) because its key is
> encoded in any of the child keys.
>
> There are many more examples where you have to think different, but in
> general: It makes sense to have entity groups where they persist in
> reality: users - comments, users - addresses, bank accounts -
> transactions, and so forth...
>
> Hope this helps,
> Fred
>
> On 3 Aug., 20:28, Vikas Hazrati  wrote:
>
>
>
> > Hi Fred,
>
> > Thanks for your response. This is what I suspected too that the entity
> > groups might not be able to change. This actually brings me to the
> > conclusion that we might not want to keep any owned entities at all.
> > We are in the process of converting a legacy application to GAE and in
> > the process we have been breaking out relationships due to multiple
> > problems. I would write about all the problems that we faced and the
> > workarounds and link it here.
> > This relationship was probably one of the last bastions that we had
> > remaining. With what you mentioned this might have to be broken too
> > since a user can move around departments as a valid business case.
>
> > So let me ask the community this question, does anyone see the benefit
> > of maintaining relations at all? using JPA/JDO. From the complex
> > queries that a normal web app would have you would fall into
> > situations where you would need to use more and more of unowned
> > relationships. Is that true? or am I missing something.
>
> > Regards | Vikaswww.inphina.comwww.thoughts.inphina.com
>
> > On Aug 3, 10:00 pm, Frederik Pfisterer  wrote:
>
> > > You have to use unowned relationships and not place the department and
> > > the user in the same entity group. 
> > > See:http://code.google.com/intl/de-DE/appengine/docs/java/datastore/relat...
> > > use for UserDepartment:
> > > private Set users = new HashSet();
> > > and for User:
> > > private Key userDepartmentKey;
>
> > > Entity groups cannot be changed once being established.
> > > If you want the relationships like you have them, you would have to
> > > change the Key of the User object (it's identity) to place it in the
> > > entity group of another department, since the department's (parent)
> > > key is part of the user key like in a path.
>
> > > Cheers,
> > > Fred
>
> > > On 3 Aug., 15:09, Vikas Hazrati  wrote:
>
> > > > Oops I somehow managed to hit the submit without the full question...
> > > > Apologies...Let me start again
>
> > > > I have 2 entities UserDepartment and User, which are defined as
> > > > follows
> > > > @Entity
> > > > public class UserDepartment extends DomainObject > > > UserDepartment>
> > > > {
> > > >         @Id
> > > >         @GeneratedValue(strategy = GenerationType.IDENTITY)
> > > >         private Long departmentId;
> > > >         @OneToMany(mappedBy = "userDepartment", cascade =
> > > > CascadeType.ALL, fetch=FetchType.EAGER)
> > > >         private Set users = new HashSet();
>
> > > > and
>
> > > > @Entity
> > > > public class User extends DomainObject {
> > > >         @Id
> > > >         @GeneratedValue(strategy = GenerationType.IDENTITY)
> > > >         @Extension(vendorName = "datanucleus", key = "gae.encoded-pk",
> &

[appengine-java] Re: Changing the Parent of a child entity

2010-08-03 Thread Vikas Hazrati
Hi Fred,

Thanks for your response. This is what I suspected too that the entity
groups might not be able to change. This actually brings me to the
conclusion that we might not want to keep any owned entities at all.
We are in the process of converting a legacy application to GAE and in
the process we have been breaking out relationships due to multiple
problems. I would write about all the problems that we faced and the
workarounds and link it here.
This relationship was probably one of the last bastions that we had
remaining. With what you mentioned this might have to be broken too
since a user can move around departments as a valid business case.

So let me ask the community this question, does anyone see the benefit
of maintaining relations at all? using JPA/JDO. From the complex
queries that a normal web app would have you would fall into
situations where you would need to use more and more of unowned
relationships. Is that true? or am I missing something.

Regards | Vikas
www.inphina.com
www.thoughts.inphina.com

On Aug 3, 10:00 pm, Frederik Pfisterer  wrote:
> You have to use unowned relationships and not place the department and
> the user in the same entity group. 
> See:http://code.google.com/intl/de-DE/appengine/docs/java/datastore/relat...
> use for UserDepartment:
> private Set users = new HashSet();
> and for User:
> private Key userDepartmentKey;
>
> Entity groups cannot be changed once being established.
> If you want the relationships like you have them, you would have to
> change the Key of the User object (it's identity) to place it in the
> entity group of another department, since the department's (parent)
> key is part of the user key like in a path.
>
> Cheers,
> Fred
>
> On 3 Aug., 15:09, Vikas Hazrati  wrote:
>
>
>
> > Oops I somehow managed to hit the submit without the full question...
> > Apologies...Let me start again
>
> > I have 2 entities UserDepartment and User, which are defined as
> > follows
> > @Entity
> > public class UserDepartment extends DomainObject > UserDepartment>
> > {
> >         @Id
> >         @GeneratedValue(strategy = GenerationType.IDENTITY)
> >         private Long departmentId;
> >         @OneToMany(mappedBy = "userDepartment", cascade =
> > CascadeType.ALL, fetch=FetchType.EAGER)
> >         private Set users = new HashSet();
>
> > and
>
> > @Entity
> > public class User extends DomainObject {
> >         @Id
> >         @GeneratedValue(strategy = GenerationType.IDENTITY)
> >         @Extension(vendorName = "datanucleus", key = "gae.encoded-pk",
> > value = "true")
> >         private String encodedKey;
> >         @Extension(vendorName = "datanucleus", key = "gae.pk-id",
> > value = "true")
> >         private Long userId;
> >         private String username;
> >         @ManyToOne(fetch = FetchType.EAGER)
> >         private UserDepartment userDepartment;
>
> > As you would notice that UserDepartment is the parent of the User. Now
> > once I persist the entity group, i want to modify the user so that it
> > belongs to a different department now.
>
> > What is the best way to do that?
>
> > If i remove the UserDepartment from the User and then assign a new
> > UserDepartment to it then I get into the issue of trying to access
> > multiple entity groups in the same transaction.
>
> > Regards | Vikaswww.inphina.com
>
> > On Aug 3, 6:05 pm, Vikas Hazrati  wrote:
>
> > > I have 2 entities UserDepartment and User, which are defined as
> > > follows
>
> > > @Entity
> > > public class UserDepartment extends DomainObject
> > > {
>
> > >         @Id
> > >         @GeneratedValue(strategy = GenerationType.IDENTITY)
> > >         private Long departmentId;
>
> > > and
>
> > > @Entity
> > > public class User extends DomainObject {
>
> > >         @Id
> > >         @GeneratedValue(strategy = GenerationType.IDENTITY)
> > >         @Extension(vendorName = "datanucleus", key = "gae.encoded-pk", 
> > > value
> > > = "true")
> > >         private String encodedKey;
>
> > >         @Extension(vendorName = "datanucleus", key = "gae.pk-id", value =
> > > "true")
> > >         private Long userId;
>
> > >         private String username;
> > > @ManyToOne(fetch = FetchType.EAGER)
> > >         private UserDepartment userDepartment;

-- 
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-j...@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: Changing the Parent of a child entity

2010-08-03 Thread Vikas Hazrati
Oops I somehow managed to hit the submit without the full question...
Apologies...Let me start again

I have 2 entities UserDepartment and User, which are defined as
follows
@Entity
public class UserDepartment extends DomainObject
{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long departmentId;
@OneToMany(mappedBy = "userDepartment", cascade =
CascadeType.ALL, fetch=FetchType.EAGER)
private Set users = new HashSet();

and

@Entity
public class User extends DomainObject {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Extension(vendorName = "datanucleus", key = "gae.encoded-pk",
value = "true")
private String encodedKey;
@Extension(vendorName = "datanucleus", key = "gae.pk-id",
value = "true")
private Long userId;
private String username;
@ManyToOne(fetch = FetchType.EAGER)
private UserDepartment userDepartment;


As you would notice that UserDepartment is the parent of the User. Now
once I persist the entity group, i want to modify the user so that it
belongs to a different department now.

What is the best way to do that?

If i remove the UserDepartment from the User and then assign a new
UserDepartment to it then I get into the issue of trying to access
multiple entity groups in the same transaction.

Regards | Vikas
www.inphina.com


On Aug 3, 6:05 pm, Vikas Hazrati  wrote:
> I have 2 entities UserDepartment and User, which are defined as
> follows
>
> @Entity
> public class UserDepartment extends DomainObject
> {
>
>         @Id
>         @GeneratedValue(strategy = GenerationType.IDENTITY)
>         private Long departmentId;
>
> and
>
> @Entity
> public class User extends DomainObject {
>
>         @Id
>         @GeneratedValue(strategy = GenerationType.IDENTITY)
>         @Extension(vendorName = "datanucleus", key = "gae.encoded-pk", value
> = "true")
>         private String encodedKey;
>
>         @Extension(vendorName = "datanucleus", key = "gae.pk-id", value =
> "true")
>         private Long userId;
>
>         private String username;
> @ManyToOne(fetch = FetchType.EAGER)
>         private UserDepartment userDepartment;

-- 
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-j...@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] Changing the Parent of a child entity

2010-08-03 Thread Vikas Hazrati
I have 2 entities UserDepartment and User, which are defined as
follows

@Entity
public class UserDepartment extends DomainObject
{

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long departmentId;

and

@Entity
public class User extends DomainObject {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Extension(vendorName = "datanucleus", key = "gae.encoded-pk", value
= "true")
private String encodedKey;

@Extension(vendorName = "datanucleus", key = "gae.pk-id", value =
"true")
private Long userId;

private String username;
@ManyToOne(fetch = FetchType.EAGER)
private UserDepartment userDepartment;

-- 
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-j...@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] Changing the Parent of a child entity

2010-08-03 Thread Vikas Hazrati
I have 2 entities UserDepartment and User, which are defined as
follows

@Entity
public class UserDepartment extends DomainObject
{

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long departmentId;

and

@Entity
public class User extends DomainObject {

@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Extension(vendorName = "datanucleus", key = "gae.encoded-pk", value
= "true")
private String encodedKey;

@Extension(vendorName = "datanucleus", key = "gae.pk-id", value =
"true")
private Long userId;

private String username;
@ManyToOne(fetch = FetchType.EAGER)
private UserDepartment userDepartment;

-- 
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-j...@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] Field was not detached when you detached the object. Either dont access this field, or detach it when detaching the object.

2010-08-02 Thread Vikas Hazrati
I have the following scenario of an unowned relationship between a
User and UserRoles

public class User extends DomainObject {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Extension(vendorName = "datanucleus", key = "gae.encoded-pk", value
= "true")
private String encodedKey;

@Extension(vendorName = "datanucleus", key = "gae.pk-id", value =
"true")
private Long userId;
private String username;
private String password;
private Long salt;


//  @Basic(fetch = FetchType.EAGER)
private Set userRoleKeys = new HashSet();
@Transient
private Set userRoles = new HashSet();

As you would notice, I am using JPA, The UserRoles collection is
marked transient and I am adding the keys for the UserRoles in the
userRoleKeys Set.

So far so good.

Now, when I retrieve the user and try to access the userRoles, i get
the above mentioned error.
The error gets resolved when I use the @Basic annotation with the
userRoleKeys (see the commented line), however, that conflicts with
another functionality. If I want to add roles to the user and then
merge it then that does not work. It continues to retain the earlier
set if I have the @Basic annotation applied.

Questions

1) How do I detach the userRoleKeys set from the user object. I
already have the following in my persistence.xml


2) Why doesn't the merge update the set when I add the @Basic
annotation?
3) Is there a standard way of resolving the above situation?

-- 
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-j...@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: Or filters cannot be applied to multiple properties

2010-07-14 Thread Vikas Hazrati
Hi John, I quickly skimmed over the twig project, it seems that it
works directly on top of the datastore. Does that mean that I do not
need to use datanucleus or does twig work in conjunction with that and
I would need both.

On Jul 14, 9:30 pm, John Patterson  wrote:
> Twig Persist has support for OR queries on multiple properties.
>
> http://code.google.com/p/twig-persist/
>
> You example is coded like this:
>
> TypedFindCommand command =
>         datastore.find().type(Person.class).addFilter)"active", EQUAL, true);
> command.addChildQuery().addFilter("firstName", EQUAL, aFirstName);
> command.addChildQuery().addFilter("lastName", EQUAL, aLastName);
> Iterator people = command.returnResultsNow();
>
> On 14 Jul 2010, at 19:10, Vikas Hazrati wrote:
>
>
>
> > Further to my previous question
> >http://groups.google.com/group/google-appengine/browse_thread/
> > thread/...
> > in which we were getting the following error 
> > 'or' filters can only check equality
> > Now for the sake of datanucleus and datastore we changed the
> > functionality to be equality for the time being
> > so the query reads like
> > @NamedQuery(name="User.findActiveByUsernamePattern",
> >                query="SELECT DISTINCT user " +
> >                                "FROM User as user " +
> >                                "WHERE (firstName = :pattern OR
> > lastName = :pattern) " +
> >                                "AND (active = true) " +
> >                                "ORDER BY firstName, lastName")
> > and now I get
> > org.datanucleus.store.appengine.query.DatastoreQuery
> > $UnsupportedDatastoreFeatureException: Problem with query  > FROM
> > User as user WHERE (user.firstName = :pattern OR user.lastName
> > = :pattern) AND (user.active = true) ORDER BY user.firstName,
> > user.lastName>: Or filters cannot be applied to multiple properties
> > (found both firstName and lastName).
> > A search on the net does not show too many results for the problem
> > that we are facing.
> > Are we the only ones facing this issue? No one else is trying to port
> > a legacy application to GAE? Isn't this quite a normal routine
> > query in JPA???
> > @datanucleus, @gae please respond.
> > Regards | Vikas
> >www.inphina.com
> >www.thoughts.inphina.com
>
> > --
> > 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 
> > athttp://groups.google.com/group/google-appengine-java?hl=en
> > .

-- 
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-j...@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: Or filters cannot be applied to multiple properties

2010-07-14 Thread Vikas Hazrati
Thanks for the link Simon

On Jul 14, 7:34 pm, Simon  wrote:
> The "Query Filters" section under the following link it explains the
> problem you're 
> hitting:http://code.google.com/appengine/docs/java/datastore/queriesandindexe...
>
> On Jul 14, 1:10 pm, Vikas Hazrati  wrote:
>
>
>
> > Further to my previous 
> > questionhttp://groups.google.com/group/google-appengine/browse_thread/thread/...
> > in which we were getting the following error 
> > 'or' filters can only check equality
> > Now for the sake of datanucleus and datastore we changed the
> > functionality to be equality for the time being
> > so the query reads like
> > @NamedQuery(name="User.findActiveByUsernamePattern",
> >                 query="SELECT DISTINCT user " +
> >                                 "FROM User as user " +
> >                                 "WHERE (firstName = :pattern OR
> > lastName = :pattern) " +
> >                                 "AND (active = true) " +
> >                                 "ORDER BY firstName, lastName")
> > and now I get
> > org.datanucleus.store.appengine.query.DatastoreQuery
> > $UnsupportedDatastoreFeatureException: Problem with query  > FROM
> > User as user WHERE (user.firstName = :pattern OR user.lastName
> > = :pattern) AND (user.active = true) ORDER BY user.firstName,
> > user.lastName>: Or filters cannot be applied to multiple properties
> > (found both firstName and lastName).
> > A search on the net does not show too many results for the problem
> > that we are facing.
> > Are we the only ones facing this issue? No one else is trying to port
> > a legacy application to GAE? Isn't this quite a normal routine
> > query in JPA???
> > @datanucleus, @gae please respond.
> > Regards | Vikaswww.inphina.comwww.thoughts.inphina.com

-- 
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-j...@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] Loading Seed Data for Unit Testing

2010-07-14 Thread Vikas Hazrati
Hi,
We are using JPA for our Dao's to interact with the datastore. I was
wondering is there is a way to load seed data for unit testing. I can
insert the entities using JPA in the setup() method here
private final LocalServiceTestHelper helper = new
LocalServiceTestHelper(new LocalDatastoreServiceTestConfig());
@Before
public void setUp() {
helper.setUp();
}
but I was wondering if the LocalServiceTestHelper / anyother has a
convenience method for loading the seed data from an XML file. The
data would be present like this


 
  
  
  
  
  

Regards | Vikas
www.inphina.com
www.thoughts.inphina.com

-- 
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-j...@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] Or filters cannot be applied to multiple properties

2010-07-14 Thread Vikas Hazrati
Further to my previous question
http://groups.google.com/group/google-appengine/browse_thread/thread/...
in which we were getting the following error 
'or' filters can only check equality
Now for the sake of datanucleus and datastore we changed the
functionality to be equality for the time being
so the query reads like
@NamedQuery(name="User.findActiveByUsernamePattern",
query="SELECT DISTINCT user " +
"FROM User as user " +
"WHERE (firstName = :pattern OR
lastName = :pattern) " +
"AND (active = true) " +
"ORDER BY firstName, lastName")
and now I get
org.datanucleus.store.appengine.query.DatastoreQuery
$UnsupportedDatastoreFeatureException: Problem with query : Or filters cannot be applied to multiple properties
(found both firstName and lastName).
A search on the net does not show too many results for the problem
that we are facing.
Are we the only ones facing this issue? No one else is trying to port
a legacy application to GAE? Isn't this quite a normal routine
query in JPA???
@datanucleus, @gae please respond.
Regards | Vikas
www.inphina.com
www.thoughts.inphina.com

-- 
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-j...@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] 'or' filters can only check equality

2010-07-14 Thread Vikas Hazrati
Hi,
We have the following named query in JPA which we want to execute on
the datastore
@NamedQuery(name="User.findActiveByUsernamePattern",
query="SELECT DISTINCT user " +
"FROM User as user " +
"WHERE firstName like :pattern OR
lastName like :pattern " +
"AND active = true " +
"ORDER BY firstName")
when we execute the test, we get the following error
org.datanucleus.store.appengine.query.DatastoreQuery
$UnsupportedDatastoreFeatureException: Problem with query : 'or' filters can only check
equality
What is the best way to resolve this? we can write 2 queries one for
firstName and other for lastname but that is ugly.
Regards | Vikas
www.inphina.com
www.thoughts.inphina,com

-- 
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-j...@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.