Saturday, July 11, 2015

Unicode characters in Java comments are executed as a normal code!

This is actually an interesting case about the Unicode in Java. I'm sharing with you this question from Stack Overflow about this case with a good answer explaining it.
http://stackoverflow.com/questions/30727515/why-is-executing-java-code-in-comments-with-certain-unicode-characters-allowed

Friday, July 10, 2015

Bidirectional relationship with Jackson in REST web services in WildFly

This is an example for a Bidirectional relationship between Java entities in a REST web service with the Jackson API.

1- Assume we have a bidirectional relationship between two entities Parent and Child.
2- Using MySQL workbench to generate the SQL schema file for this two tables.
DROP SCHEMA IF EXISTS `bidirectional_schema` ;
CREATE SCHEMA IF NOT EXISTS `bidirectional_schema` DEFAULT CHARACTER SET utf8 ;
USE `bidirectional_schema` ;

-- -----------------------------------------------------
-- Table `bidirectional_schema`.`PARENT`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `bidirectional_schema`.`PARENT` ;

CREATE  TABLE IF NOT EXISTS `bidirectional_schema`.`PARENT` (
  `PARENT_ID` INT NOT NULL ,
  `PARENT_CONTENT` VARCHAR(45) NULL ,
  PRIMARY KEY (`PARENT_ID`) )
ENGINE = InnoDB;

-- -----------------------------------------------------
-- Table `bidirectional_schema`.`CHILD`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `bidirectional_schema`.`CHILD` ;

CREATE  TABLE IF NOT EXISTS `bidirectional_schema`.`CHILD` (
  `CHILD_ID` INT NOT NULL ,
  `CHILD_CONTENT` VARCHAR(45) NULL ,
  `PARENT_PARENT_ID` INT NOT NULL ,
  PRIMARY KEY (`CHILD_ID`) ,
  INDEX `fk_CHILD_PARENT_idx` (`PARENT_PARENT_ID` ASC) ,
  CONSTRAINT `fk_CHILD_PARENT`
    FOREIGN KEY (`PARENT_PARENT_ID` )
    REFERENCES `bidirectional_schema`.`PARENT` (`PARENT_ID` )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

Installing WebSphere Liberty Profile server then adding features

IBM WebSphere Liberty Profile is a really fast and easy to to use application server. According to the About page, the latest stable release of Liberty is Java EE 6 Web Profile-certified and they’re gradually adding Java EE 7 technologies. Any Java EE 6 applications you write on Liberty can be deployed in production, without changes, on WebSphere Application Server which is certified for the full Java EE 6 platform. You can, of course, deploy to production on Liberty too. Bellow we will see how to start working on it and adding some features to it.

1. Download the Liberty server from this link as a stand alone server.
https://developer.ibm.com/wasdev/downloads/liberty-profile-using-non-eclipse-environments/
Also you can embed it in Eclipse after installing the WebSphere Developer Tools through this link:
https://developer.ibm.com/wasdev/downloads/liberty-profile-using-eclipse/
The Eclipse Marketplace would start like this for installing an adapter for the Eclipse.