Sunday, November 6, 2011

plusone-button + 1 to your web site.

By adding these icon you can get benefits to send the information about
your website to other users.


There is some basic steps to add the g+ button in your web site.

  • add this tag in body part of jsp/html
        <g:plusone></g:plusone>
and in the head section call the js function



<script type="text/javascript">
      window.___gcfg = {
        lang: 'en-US'
      };


      (function() {
        var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
        po.src = 'https://apis.google.com/js/plusone.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
      })();
    </script>




Change Hibernate Mapping to Retrieve a List instead of a Set


Table 1- Employee
Table 2 - Destination
Relationship : Employee has multiple destinations
when you did the reverse engineering it will give the Set in Employee table.
Now we want to convert the set into list.so first of all we change the Set
object into the java.util.list object in the POJO file of employee
(which is made in dao folder when you make the reverse engineering )

Example: Set 
public class Employeeaddress implements java.io.Serializable {
private Set destinations = new HashSet(0);
/** full constructor */
public Employeeaddress( Set destinations){
    this.destinations = destinations;
    }

public Set getDestinations() {
return this.destinations;
}
public void setDestinations(Set destinations) {
this.destinations = destinations;
}
}

Convert into list :
Note: Change the set to list

  • private List destinations = new ArrayList();


public List getDestinations() {
return this.destinations;
}

public void setDestinations(List destinations) {
this.destinations = destinations;
}


  • 3- Change into the HBM file .


<list name="destinations" table="destinations">
    <key column="ID" />
    <list-index column="Location" />
   <one-to-many class="com.doa.Destination"/>
</list>


OR another example of List:

<list name="carComponents"
        table="CarComponents">
    <key column="carId"/>
    <list-index column="sortOrder"/>
    <composite-element class="CarComponent">
        <property name="price"/>
        <property name="type"/>
        <property name="serialNumber" column="serialNum"/>
    </composite-element>
</list>


For more information : http://docs.jboss.org/hibernate/core/3.3/reference/en/html/collections.html