Archive for the ‘ Notes ’ Category

just launched achivy.com…

Hi everybody, this was my surprise project , achivy.com my first startup, my first ruby on rails project :)

you can check the  about page  but it is simply a gamification platform for lots of social sites and more, it now supports foursquare, gowalla, stackoverflow etc….

Achivy adds some fun and gamification to your social life. Add Twitter,Tumblr, Foursquare Gowalla , Flickr, Stackoverflow, Klout and many other applications to your profile to see how many achievements, badges,scores you have and follow your progress. You can keep up with your friends, and see the other people’s achievements and activities – achivies.

more to come soon…

todo list

checklist

Image by alancleaver_2000 via Flickr

it has been a long time since I posted  :( so it would  be really good to put some targets and build a list of them. otherwise I will be lying on my coach all the time.

  • ruby on rails experience : so far so amazing.
  • yagdao :  finalize and release 1.0
  • startupweekend amsterdam notes ! anybody for utrecht ?
  •  ???, surprise
hope to implement all those and do something interesting here
see you soon

Release Notes: com.altuure.yagdao-0.3.jar

Append Method handler

Another dynamic query builder. But this one , use simple StringBuilder instead of trying to parse the argument.  So more fast and adjustable dynamic query builder

For more see test cases and example dao

   @YMethod(type = YMethodType.APPEND,select = "pbyte,count(id)",groupBy = "pbyte")
    List<SimpleBean> append2(@YParameter("pint>=?") int i);

    @YMethod(type = YMethodType.APPEND,select = "pbyte,count(id)",groupBy = "pbyte",having = "count(id)>10")
    List<SimpleBean> append3(@YParameter("pint>=?") int i);

group and having support with aggregation support

Append and JPA criteria methods now support Projections

Execute Method handler

bulk method support

   @YMethod(type = YMethodType.EXECUTE,query = "update SimpleBean set pint=:newInt where id=:id ")
    int execute1(@YParameter(value = "newInt") int newInt,@YParameter(value = "id") long id);

experimental criteria query parser for JPA

Criteria method is now support more sophisticated queries . please see test cases and example dao

    @YMethod(type = YMethodType.CRITERIA)
    SearchResultList<SimpleBean> criteria2(@YParameter("pint >=") Integer arg1,@YParameter("pint <=") Integer arg2);

    @YMethod(type = YMethodType.CRITERIA)
    SearchResultList<SimpleBean> criteria3(@YParameter("pstring is null") boolean apply);

    @YMethod(type = YMethodType.CRITERIA)
    SearchResultList<Object> criteria2CheckApplied(@YParameter("pint>=20000") boolean apply1,@YParameter( "pint<=50000") boolean apply2);

com.altuure.yagdao-0.2.jar

I published for version of the yagdao (Yet Another Generic DAO) finally.

this version is a little bit experimental but stable.

yagdao is an generic dao framework  that would be enabled by annotations.

simple step to go through for setup read more

  • add jar into your classpath
  • extend GenericDAO

moreover you can implement custom method read more

hibernate criteria API bug: unnecessary fetch

I unfortunately came across a bug on hibernate and I think it is pretty match important for anyone who is using hibernate criteria API and caring about performance.

Although this is an important, it is a hidden bug unless you trace you generated SQL for hibernate.

simply the two lines of code below should generate same SQL

        Criteria rootCriteria = session.createCriteria(OrderItem.class);
        Criteria criteria = rootCriteria.createCriteria("order").createCriteria("customer");
        List<OrderItem> list1 = criteria.add(Restrictions.eq("city", "city-1")).list();
        List<OrderItem> list2 = session.createQuery("select s from OrderItem s where s.order.customer.city=?").setString(0,"city-1").list();
        assertEquals(list1, list2);

but when you trace the generated SQL you can see the huge difference. it simply changes fetchmode defaults and ignore any manual fetchmode setting

SQL from criteria API

select this_.id as id1_2_, this_.name as name1_2_, this_.order_id as order5_1_2_, this_.product_id as product6_1_2_, this_.quantity as quantity1_2_, this_.totalPrice as totalPrice1_2_, order1_.id as id0_0_, order1_.customer_id as customer7_0_0_, order1_.deliveryDate as delivery2_0_0_, order1_.name as name0_0_, order1_.orderDate as orderDate0_0_, order1_.priority as priority0_0_, order1_.totalValue as totalValue0_0_, customer2_.id as id3_1_, customer2_.city as city3_1_, customer2_.name as name3_1_ from erp_orderitem this_ inner join erp_order order1_ on this_.order_id=order1_.id inner join erp_customer customer2_ on order1_.customer_id=customer2_.id where customer2_.city=?

SQL generate from hql

select orderitem0_.id as id1_, orderitem0_.name as name1_, orderitem0_.order_id as order5_1_, orderitem0_.product_id as product6_1_, orderitem0_.quantity as quantity1_, orderitem0_.totalPrice as totalPrice1_ from erp_orderitem orderitem0_ cross join erp_order order1_ cross join erp_customer customer2_ where orderitem0_.order_id=order1_.id and order1_.customer_id=customer2_.id and customer2_.city=?

you can find more discussion on

https://forums.hibernate.org/viewtopic.php?f=1&t=962905

http://opensource.atlassian.com/projects/hibernate/browse/HHH-3524

PS:if you use hibernate criteria API , please vote for the bug.

Ruby on Rails experience of a java developer

Ruby on Rails logo

Image via Wikipedia

Although it has not been a long time since I started to develop a small rails application, I would like to share notes.

the first point ,for me and for all the Java developers like me, should be: “what kind of language is this  ???” :) yes it is not  structured and well defined like Java , there are lots of tricks going around.  Even the simple for loops seems complex.

and for such a tricky language you cannot expect to find a full-functional CTRL-SPACE support. and for me it is still a pain.

To save yourself from any more pain I would suggest you to setup your environment with instantRails and aptana radrails.

however after you get used to this alien language, you would start to enjoy it. that is what started to do.  I really understood the real meaning of light-weight and agile. Although I do feel myself as secure and powerful as in Java, I still enjoyed it.

what was missing grails?

almost a year ago I tried grails also, I have seen some sparkles in it but that wasn’t the tool I have been looking for. it was not agile, the development cycle is painful. it was a pre-configured spring-hibernate setup with groovy.

the pain of grails does come from its power actually, spring-hibernate. it is really HEAVY.

The Sparkles

I don’t have too much experience, but I can easily say, development with it is way faster than Java or grails and way powerful than PHP.if you are looking for easy way to develop a web site that is the language you should look first.  It has  good and simple web-life cycle and built in support for web standard like json,xml and ajax.

The Volcano: Java

Although rails has good point it is not as powerful as java, and it is not complete alternative to java either.(don’t hesitate  to post your comments). So for the moment I am searching for integration strategies.

Clean database schema with inheritance

ORM Diagram

It is very common way of usage that  when ever you need some new attribute for your model objects/table you add a new column to the related database table.  After several requirements you will notice: Read more