{"id":1672,"date":"2010-09-14T20:11:15","date_gmt":"2010-09-14T14:41:15","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=1672"},"modified":"2010-09-14T20:11:15","modified_gmt":"2010-09-14T14:41:15","slug":"first-experience-with-google-app-engine","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/first-experience-with-google-app-engine\/","title":{"rendered":"First experience with Google App Engine"},"content":{"rendered":"<p>A few days back I had chance to work on a googleApp using <strong>GORM-JPA plugin,version (0.7.1)<\/strong>. I came across a few problems which are as given below.<br \/>\n  Consider the domain : Country -> has many States.<\/p>\n<li>At first it appeared that the one to  many relationships are to be managed using annotations like :<\/li>\n<blockquote>\n<pre lang=\"groovy\">\r\nCountry {\r\n  @OneToMany(mappedBy = \"state\")\r\n  List<State> states\r\n}\r\n\r\nState state {\r\n  @ManyToOne\r\n  State state\r\n}\r\n<\/pre>\n<\/blockquote>\n<li>\nThe <strong>Country.get()<\/strong> worked fine but <strong>State.get()<\/strong> did not work. I think it is due to the fact that Big Table stores states as multivalued attributes of the Country. So to make it work I myself added a field (countryId) to State domain, storing the Id of the Country it belongs to as foreign key. So everytime I needed to find the State from its Id attribute, I first used to search all the States belonging to a Country, and then from these states search for a state with a particular id.\n<\/li>\n<blockquote>\n<pre lang=\"groovy\">\r\n List states = State.findAll(\"SELECT s FROM State s WHERE s.countryId='${params.countryId}'\")\r\n def pollOptionInstance = pollOptions.find {it.id == params.id.toLong()} \r\n<\/pre>\n<\/blockquote>\n<li>\n <strong>Domain.findAllBy()<\/strong> and <strong>Domain.findBy()<\/strong> do not seem to work. I used <strong>Domain.findAll{query}<\/strong> most of the time to query a domain.\n<\/li>\n<li>\nEach <strong>save()<\/strong> operation needs to be contained in a transaction\n<\/li>\n<li>\nOnly <strong>one object<\/strong> can be saved in <strong>one transaction<\/strong>\n<\/li>\n<li>\n I couldn&#8217;t save <strong>State<\/strong> object with the reference of the <strong>Country<\/strong> object in it. It did not allow me,  so I stored the countryId instead of the whole object  (which exactly is what gorm does for you). So this meant  I had to manage hasMany relationships on my own, by storing the refenceIds instead of the objects itself (<strong>so annotations were of no use<\/strong>).\n<\/li>\n<p>Hope this helps. You are welcome to share your thoughts on it.<\/p>\n<p>Imran  Mir<br \/>\nimran@intelligrap.com<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A few days back I had chance to work on a googleApp using GORM-JPA plugin,version (0.7.1). I came across a few problems which are as given below. Consider the domain : Country -> has many States. At first it appeared that the one to many relationships are to be managed using annotations like : Country [&hellip;]<\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":1},"categories":[7],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/1672"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=1672"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/1672\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=1672"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=1672"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=1672"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}