Updates from November, 2011 Toggle Comment Threads | Keyboard Shortcuts

  • Subinkrishna Gopi 4:17 pm on November 24, 2011 Permalink |
    Tags: , groovy, hello world, , scripting   

    Hello, Groovy! 

    My new job demands me to learn a lot of new things that I never wanted to! Today I wrote my first ever Groovy script. And it compiled and run! Awesome 🙂

    package subin.groovy;
    
    /**
     * Hello, World!
     *
     * @author Subinkrishna Gopi
     */
    class HelloWorld
    {
    	static def aString = "Hello, World!"
    	static void main(args)
    	{
    		println("${aString.toUpperCase()} it's a nice day today :)")
    	}
    }
    
     
  • Subinkrishna Gopi 3:47 pm on November 15, 2010 Permalink |
    Tags: , , knowledge, technology, vadiraj   

    Introducing Vadi’s blog! 

    Thoughts, Paradoxes, Contemplation, Musings .. is a blog by Vadiraj A – my guide, friend & colleague, where he shares his thoughts, views, ideas and knowledge on life, technology and entrepreneurship.

    About Vadiraj | Read his blog | LinkedIn profile

     
  • Subinkrishna Gopi 3:29 pm on November 4, 2010 Permalink |
    Tags: , , , ,   

    Today’s read – How To Build A Mobile Website 

    This one is really helpful. How To Build A Mobile Website. This article talks about the stylesheets, mobile stylesheets, customizing them, how to reduce the bandwidth usage and handling iPad/iPhone.

    Over the past few years, mobile web usage has considerably increased to the point that web developers and designers can no longer afford to ignore it. In wealthy countries, the shift is being fueled by faster mobile broadband connections and cheaper data service.  However, a large increase has also been seen in developing nations where people have skipped over buying PCs and gone straight to mobile.

    Unfortunately, the mobile arena introduces a layer of complexity that can be difficult for developers to accommodate.  Mobile development is more than cross-browser, it should be cross-platform.  The vast number of mobile devices makes thorough testing a practical impossibility, leaving developers nostalgic for the days when they only had to support legacy browsers.

    Source: Smashing Magazine

    Read the article

     
  • Subinkrishna Gopi 11:11 am on October 28, 2010 Permalink |
    Tags: , , , guide, how-to, , simple, tutorial   

    Today’s read: Get Started Developing for Android with Eclipse 

    This one is pretty good. Perhaps one of the very useful how-tos! I read this article in smashingmagazine.com a few days back. I was thinking of sharing it from that moment. It’s better late than never. The article talks a lot of things. From about installing the Android SDK, configuring it and even about writing a sample application.

    There’s a lot to get excited about in mobile application development today. With increasingly sophisticated hardware, tablet PCs and a variety of software platforms (Symbian OS, iOS, WebOS, Windows Phone 7…), the landscape for mobile developers is full of opportunities — and a little complex as well.

    So much choice can be overwhelming when you just want to get started building mobile applications. Which platform should you choose? What programming language should you learn? What kit do you need for your planned project? In this tutorial, you’ll learn how to start writing applications for Android, the open-source mobile operating system popularized by Google.

    Source: Smashing Magazine

    Read the article | http://developer.android.com

     
  • Subinkrishna Gopi 5:56 pm on October 18, 2010 Permalink |
    Tags: , DBMS, , ejb3, entity, hibernate, , ORM, query, , session   

    How-to: Write a named query for an entity bean with composite key 

    I was working on an EJB3 project where I had to write an entity bean with a composite primary key. And I needed to write a named query to which had to use a sub set of the composite key. And this is what I did.

    The entity bean and the composite key:

    import javax.persistence.Column;
    import javax.persistence.EmbeddedId;
    import javax.persistence.Entity;
    import javax.persistence.NamedQueries;
    import javax.persistence.NamedQuery;
    import javax.persistence.Table;
    
    @Entity
    @Table (name = "myTable")
    public class MyEntityBean implements Serializable
    {
        @EmbeddedId
        private MyCompositeKey key;
    
        // Other instance members
    
        @Column (name = "value")
        private String value;
    
        // Getters & setters
        ...
    }
    
    import java.io.Serializable;
    import javax.persistence.Column;
    import javax.persistence.Embeddable;
    
    @Embeddable
    public class MyCompositeKey implements Serializable
    {
        @Column (name = "key1", nullable = false)
        private String key1;
    
        @Column (name = "key2", nullable = false)
        private String key2;
    
        // Getters & setters
        ....
    }
    

    The equivalent database table will look like:

    +---------------+--------------+------+-----+---------+-------+
    | Field         | Type         | Null | Key | Default | Extra |
    +---------------+--------------+------+-----+---------+-------+
    | key1          | varchar(255) | NO   | PRI |         |       |
    | key2          | varchar(255) | NO   | PRI |         |       |
    | value         | varchar(255) | YES  |     |         |       |
    +---------------+--------------+------+-----+---------+-------+
    

    Writing a named query which makes use of the elements of the composite key is a li’l tricky. Take a look at the following SQL statement which tries to fetch all the records from the table for a matching key1.

    SELECT * FROM myTable WHERE key1='some value';
    

    Embedding the named query in MyEntityBean.

    @Entity
    @Table (name = "myTable")
    @NamedQueries
    ({
        @NamedQuery(
            name = "myQuery",
            query = "SELECT FROM MyEntityBean b WHERE key.key1 = :key1" )
    })
    public class MyEntityBean implements Serializable
    {
        ...
    }
    

    We should be careful about the use of the variable name in the named query. In the named query, we are supposed to use the name of the composite key exactly the same as what we have specified in the bean.

    This query can be accessed from a session bean with the help of EntityManager.

    import javax.ejb.Remote;
    import javax.ejb.Stateless;
    import javax.persistence.EntityManager;
    import javax.persistence.PersistenceContext;
    import javax.persistence.Query;
    
    @Remote
    @Stateless (name = "MySessionBean")
    public class MySessionBeanImpl implements SessionBean
    {
        @PersistenceContext
        private EntityManager entityManager;
    
        public void myMethod(String key)
        {
        	Query aQuery = null;
    
        	aQuery = this.entityManager.createNamedQuery("myQuery");
            aQuery.setParameter("key1", key);
    
            List resultList = aQuery.getResultList();
    
            .....
        }
    }
    

    Hope this helps. Have a good day 🙂

     
c
Compose new post
j
Next post/Next comment
k
Previous post/Previous comment
r
Reply
e
Edit
o
Show/Hide comments
t
Go to top
l
Go to login
h
Show/Hide help
shift + esc
Cancel