Posts

Showing posts from 2013

Bean Validation : Hibernate Validator framework

Bean Validation with Hibernate Validator framework JSR 303 This JSR will define a meta-data model and API for JavaBean TM validation based on annotations, with overrides and extended meta-data through the use of XML validation descriptors. http://jcp.org/en/jsr/detail?id=309 JSR 349 Bean Validation standardizes constraint definition, declaration and validation for the Java platform. For more information on Bean Validation and how to participate, check out http://beanvalidation.org . http://jcp.org/en/jsr/detail?id=349  Hibernate Validator Hibernate Validator 5.x is the reference implementation for JSR 349 - Bean Validation 1.1 of which Red Hat is the specification lead. http://www.hibernate.org/subprojects/validator.html Sample Implementation. In the sample implementation, we have a class User.java with validation annotations. A test class to validate the object and to print the error messages at the console. The code is completely self explanatory. User.java

Hibernate Annotations - OnetoOne Mapping

Hibernate Annotations JPA 1   One to One Mapping   Class Employee.java package com.domain; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.OneToOne; import javax.persistence.PrimaryKeyJoinColumn; import javax.persistence.Table; @Entity @Table(name = "employeeaddress") public class EmployeeAddress implements java.io.Serializable {     private static final long serialVersionUID = 1L;     // Fields     private Integer employeeid;     private String address;     private Employee employee;     // Constructors     /** default constructor */     public EmployeeAddress() {     }     /** minimal constructor */     public EmployeeAddress(Integer employeeid) {         this.employeeid = employeeid;     }     /** full constructor */     public EmployeeAddress(Integer employeeid, String address) {         this.employeeid = employeeid;         this.address = address;    

Flex IFrame library - Duplicate reload issue and multiple IFrames problem.

Issue 1 : Flex IFrame Duplicate reload At times the Flex- IFrame library recreates the IFrame with the same URL. This may be due to a possible bug in the application which creates the event to cause the IFrame to reload when not required. Whatsoever may be the root cause, but this duplicate IFrame creation reloads the URL which was already loaded, which in turn sends a http request to server. This will unwanted server load, logging, and duplicate database read/write is a performance and integrity threat. Solution The actual solution may be to find the unnecessary events which trigger the IFrame creation call. But this will not guarantee that no such new code will not be introduced in the future. The better solution would be to check the current IFrame source and the new IFrame source before loading the IFrame. A subclass of class com.google.code.flexiframe.IFrame is created and overridden the default behavior of the loadIFrame () as below. This is how Inheritance

Samsung Wifi issue

Samsung Wi-Fi PSM issue. Sometimes samsung mobile users experience issue with their wifi connectivity. The icon shows it’s connected to wifi but wifi won't work. This is because of the wifi power saver mode (PSM) is set to ON.    Wifi PSM (power saver mode) Wifi uses more power. So system is designed to turn off or disable the wifi when the user is not using the internet! Some times this prediction fails, machine thinks you are sleeping even though you are actively browsing the internet and hence it switches of the wifi! So you run out of internet connectivity! How to fix To fix this disable the power saver mode. Set it to off. Steps to disable wifi power saver mode.   Go to dial pad Dial *#0011# You will enter into the service mode screen Click the menu at the right corner Select Wifi You can see the Wifi Power Saver Mode button and it reads ON Click it and turn it OFF Exit the menu Try now - it should work without any hindrance.

Windows Default Built-In Administrator

Image
Windows Default Administrator account We have following 4 types of accounts in windows pc. Standard user Administrator User Guest User Build-In Administrator First three accounts we know and see it regular. Guest account is the one with very limited privileges for a guest session, usually we disable it. Default Administrator account is the built-in administrator account with very elevated privileges (i.e. Super User).   Usually and by default this is account is disabled and hidden.   Difference between Built in Administrator and Administrator User Administrator user – Is an un-elevated administrator account. This is controlled by UAC (User account control) by default. Though this account has complete access, any changes that require elevated admin rights will be prompted by UAC to do so. Built-in Administrator – This is an elevated administrator account, will not be monitored by UAC. This is hidden by default. This account has a we

Servlet Push

HTTP Server Push HTTP server push  is a mechanism for sending data from a web server to a web browser. HTTP server push can be achieved through several mechanisms. Http Server push also known as HTTP streaming. Most web servers offer this feature by Non parsed Headers ("Server Push"). Another way of achieving server push is by using the special MIME type called multipart/x-mixed-replace   Server Pull and Push Usually browser asks for a page or image or an object from the server and the server sends the response to the browser. This is called 'Pull' method the most common method in webserver technology. At times the server itself can send data to the browser. Its required sometimes that the server has to push the data to its clients. For example consider the cricket score card or email web clients. These kinds of data change consistently, so server has to push the content to client to synchronize the client with the server data. Client side Refresh metho

JAXB Bigdecimal/BigInteger adapter

JAXB BigDecimal / BigInteger apapters Jaxb NumberFormatException XML attributes represents null values with empty string. During unmarshalling an XML with empty value for a BigDecimal/BigInteger JAXB throws NumberFormatException. For the case of BigDecimal it will be NumberFormatException at java.math.BigDecimal.<init> and for BigInteger it can be NumberFormatException: Zero length BigInteger at java.math.BigInteger.<init> exception. To overcome this problem, Jaxb provides a feature called TypeAdapters. Using TypeAdapters we can specify how to marshall/unmarshall a particular object or complex xml type when some of its fields are not proper. For example we can instruct JAXB if BigDecimal is empty treat it as 0, don't report an exception. BigDecimal Adapter   Below is the sample BigDecimal Adapter which advices marshall and unmarshall in the event of null values. /* * * BigDecimalAdapter.java * Adapter for java.math.BigDecimal objects * */ pac

Ubuntu instalation and un-install on windows 7

Installation and un-installing ubuntu from windows   Installation   To install Ubuntu 1. Using Ubuntu desktop ISO 2. Wubi installer   Wubi installer This is the easiest and simpler way to install Ubuntu. Download Ubuntu windows installer from http://www.Ubuntu.com/download/desktop/windows-installer. This just like any other windows software installer, so you can install and uninstall Ubuntu at any time.   Ubuntu desktop ISO Download the Ubuntu desktop ISO here http://www.Ubuntu.com/download/desktop. Select 32 bit or 64 bit based on your computer. You have to create an USB/CD bootable disk with Ubuntu to install it on your computer. You can do this with different utilities. Pendrive Linux at http://www.pendrivelinux.com/ and installation instructions http://www.Ubuntu.com/download/desktop/create-a-USB-stick-on-windows linuxlive USB creator here http://www.linuxliveUSB.com/   and installation instructions http://www.linuxliveUSB.com/en/help/guide

XML to Java code generation

Image
 XML to Java code generation using CASTOR and JAXB This tutorial explains the code generation from xml to java by using Castor and JAXB in brief.  Procedure   Generate XSD from XML using CASTOR   Generate Java objects from XSD JAXB. http://castor.codehaus.org/  Each of the steps in detail below. XSD Generation    There are lot of tools available to generate XSD from XML including a few online tools. CASTOR is one such tool can be used to generate XSD form XML. Castor is the Open Source data binding framework for Java. Mainly it consists of two features Castor XML and Castor JDO. Download and install castor from http://castor.codehaus.org/ The Castor JARs, docs, DTDs, command line tools, and examples can be downloaded from http://dist.codehaus.org/castor/1.3.3-RC1/castor-1.3.3-RC1.tgz     XML Instance to Schema Follow the below steps to generate Schema from XML. Open command prompt Java_home should point to java install directory Set