gt: 		Integer betaId = beta.getId();
context: /*
   * JSmartDB - Java ORM Framework
   * Copyright (c) 2014, Jeferson Albino da Silva, All rights reserved.
   * 
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU General Public
   * License as published by the Free Software Foundation; either
   * version 3.0 of the License, or (at your option) any later version.
   * 
   * This library is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   * Lesser General Public License for more details.
   * 
   * You should have received a copy of the GNU General Public
   * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
  
  package manager;
  
  import java.math.BigDecimal;
  import java.util.Date;
  
  import junit.framework.Assert;
  
  import org.junit.After;
  import org.junit.AfterClass;
  import org.junit.BeforeClass;
  import org.junit.Test;
  
  import entity.Alpha;
  import entity.Beta;
  import entity.Delta;
  import entity.Epsilon;
  import entity.Fi;
  import entity.Gama;
  import entity.Iota;
  import entity.Omega;
  import entity.Pi;
  import entity.Psi;
  import entity.Ro;
  import entity.Sigma;
  import entity.Tau;
  
  public class UpdateTest extends AbstractTest {
  
  	private static final Integer INTEGER_UPDATE = 30;
  	private static final Boolean BOOLEAN_UPDATE = false;
  	private static final BigDecimal DECIMAL_UPDATE = new BigDecimal(50);
  	private static final Double DOUBLE_UPDATE = 40.5d;
  	private static final Float FLOAT_UPDATE = 100.0f;
  	private static final Long LONG_UPDATE = 3000l;
  	protected static final String STRING_UPDATE = "String updated";
  	protected static final String TEXT_UPDATE = "A looooooonnnnnnnnnng text that could be used in the database are now updated.";
  	protected static final Date DATE_UPDATE = new Date(1405911599000l);
  
  	@BeforeClass
  	public static void setUpDatabase() throws Exception {
  		AbstractTest.setUpDatabase();
  	}
  
  	@After
  	public void tearDown() throws Exception {
  		AbstractTest.clearDatabase();
  	}
  
  	@AfterClass
  	public static void tearDownDatabase() throws Exception {
  		AbstractTest.tearDownDatabase();
  	}
  
  	@Test(expected = RuntimeException.class)
  	public void testNullEntityUpdate() throws Exception {
  		entityManager.updateEntity(null);
  	}
  
  	@Test
  	public void testBasicEntityUpdate() throws Exception {
  		Beta beta = getBetaEntity();
  
  		entityManager.insertEntity(beta);
  		Integer betaId = beta.getId();
  		Assert.assertTrue("The beta entity must have an id.", betaId != null);
  
  		beta.setInteger(INTEGER_UPDATE);
  		beta.setBool(BOOLEAN_UPDATE);
  		beta.setDecimal(DECIMAL_UPDATE);
  		beta.setDoubli(DOUBLE_UPDATE);
  		beta.setFloati(FLOAT_UPDATE);
  		beta.setLongi(LONG_UPDATE);
  		beta.setString(STRING_UPDATE);
  		beta.setText(TEXT_UPDATE);
  
  		entityManager.updateEntity(beta);
  
  		beta = (Beta) entityManager.selectSingleEntity(beta);
  
  		Assert.assertTrue("The beta entity must not be null.", beta != null);
  		Assert.assertTrue("The beta entity must the same id after update.", beta.getId().equals(betaId));
  		Assert.assertTrue("The beta entity must have updated Integer value.", beta.getInteger().equals(INTEGER_UPDATE));
  		Assert.assertTrue("The beta entity must have updated Boolean value.", beta.getBool().equals(BOOLEAN_UPDATE));
  		Assert.assertTrue("The beta entity must have updated Decimal value.", beta.getDecimal().equals(DECIMAL_UPDATE));
  		Assert.assertTrue("The beta entity must have updated Double value.", beta.getDoubli().equals(DOUBLE_UPDATE));
  		Assert.assertTrue("The beta entity must have updated Float value.", beta.getFloati().equals(FLOAT_UPDATE));
  		Assert.assertTrue("The beta entity must have updated String value.", beta.getString().equals(STRING_UPDATE));
  		Assert.assertTrue("The beta entity must have updated Text value.", beta.getText().equals(TEXT_UPDATE));
  	}
  
  	@Test
  	public void testBasicEntityWithIntegerUpdate() throws Exception {
  		Beta beta = getBetaEntity();
  
  		entityManager.insertEntity(beta);
  		Integer betaId = beta.getId();
  		Assert.assertTrue("The beta entity must have an id.", betaId != null);
  
  		beta.setInteger(INTEGER_UPDATE);
  
  		entityManager.updateEntity(beta);
  
  		beta = (Beta) entityManager.selectSingleEntity(beta);
  
  		Assert.assertTrue("The beta entity must not be null.", beta != null);
  		Assert.assertTrue("The beta entity must the same id after update.", beta.getId().equals(betaId));
  		Assert.assertTrue("The beta entity must have updated Integer value.", beta.getInteger().equals(INTEGER_UPDATE));
  		Assert.assertTrue("The beta entity must have updated Boolean value.", beta.getBool().equals(BOOLEAN));
  		Assert.assertTrue("The beta entity must have updated Decimal value.", beta.getDecimal().equals(DECIMAL));
  		Assert.assertTrue("The beta entity must have updated Double value.", beta.getDoubli().equals(DOUBLE));
  		Assert.assertTrue("The beta entity must have updated Float value.", beta.getFloati().equals(FLOAT));
  		Assert.assertTrue("The beta entity must have updated String value.", beta.getString().equals(STRING));
  		Assert.assertTrue("The beta entity must have updated Text value.", beta.getText().equals(TEXT));
  	}
  
  	public void testEmptyEntityUpdate() throws Exception {
  		Omega omega = getOmegaEntity();
  
  		entityManager.insertEntity(omega);
  		Long omegaId = omega.getId();
  		Assert.assertTrue("The omega entity must have an id.", omegaId != null);
  
  		omega = new Omega();
  		entityManager.updateEntity(omega);
  	}
  
  	@Test
  	public void testNullAttributesEntityUpdate() throws Exception {
  		Beta beta = getBetaEntity();
  
  		entityManager.insertEntity(beta);
  		Integer betaId = beta.getId();
  		Assert.assertTrue("The beta entity must have an id.", betaId != null);
  
  		beta.setInteger(null);
  		beta.setBool(null);
  		beta.setDecimal(null);
  		beta.setDoubli(null);
  		beta.setFloati(null);
  		beta.setLongi(null);
  		beta.setString(null);
  		beta.setText(null);
  
  		entityManager.updateEntity(beta);
  
  		beta = (Beta) entityManager.selectSingleEntity(beta);
  
  		Assert.assertTrue("The beta entity must not be null.", beta != null);
  		Assert.assertTrue("The beta entity must have an id.", beta.getId().equals(betaId));
  		Assert.assertTrue("The beta entity must have updated Integer value null.", beta.getInteger() == null);
  		Assert.assertTrue("The beta entity must have updated Boolean value null.", beta.getBool() == null);
  		Assert.assertTrue("The beta entity must have updated Decimal value null.", beta.getDecimal() == null);
  		Assert.assertTrue("The beta entity must have updated Double value null.", beta.getDoubli() == null);
  		Assert.assertTrue("The beta entity must have updated Float value null.", beta.getFloati() == null);
  		Assert.assertTrue("The beta entity must have updated String value null.", beta.getString() == null);
  		Assert.assertTrue("The beta entity must have updated Text value null.", beta.getText() == null);
  	}
  
  	@Test
  	public void testMoreThanOnePkIdEntityUpdate() throws Exception {
  		// TODO: Allow more than one pk id. // Use teta entity
  	}
  
  	@Test(expected = RuntimeException.class)
  	public void testColumnExceedLengthEntityUpdate() throws Exception {
  		Beta beta = getBetaEntity();
  
  		entityManager.insertEntity(beta);
  		Integer betaId = beta.getId();
  		Assert.assertTrue("The beta entity must have an id.", betaId != null);
  
  		beta.setString(STRING_50);
  		entityManager.updateEntity(beta);
  	}
  
  	@Test
  	public void testTransientEntityUpdate() throws Exception {
  		Beta beta = getBetaEntity();
  
  		beta.setTrans("Transient value");
  		entityManager.insertEntity(beta);
  		Integer betaId = beta.getId();
  		Assert.assertTrue("The beta entity must have an id.", betaId != null);
  
  		beta.setTrans("Transient value updated");
  		entityManager.updateEntity(beta);
  
  		beta = (Beta) entityManager.selectSingleEntity(beta);
  		Assert.assertTrue("The beta entity must not be null.", beta != null);
  		Assert.assertTrue("The beta entity must have an id.", beta.getId().equals(betaId));
  		Assert.assertTrue("The beta entity must not have transiente value.", beta.getTrans() == null);
  	}
  
  	@Test
  	public void testJoinEntityUpdate() throws Exception {
  		Alpha alpha = getAlphaEntity();
  		Epsilon epsilon = getEpsilonEntity();
  		Iota iota = getIotaEntity();
  
  		iota.setAlpha(alpha);
  		iota.setEpsilon(epsilon);
  		entityManager.insertEntity(iota);
  		
  		Integer alphaId = alpha.getId();
  		Integer epsilonId = epsilon.getId();
  		Assert.assertTrue("The alpha entity must have an id.", alphaId != null);
  		Assert.assertTrue("The epsilon entity must have an id.", epsilonId != null);
  
  		iota.setInteger(INTEGER_UPDATE);
  		iota.setBool(BOOLEAN_UPDATE);
  		iota.setDecimal(DECIMAL_UPDATE);
  		iota.setDoubli(DOUBLE_UPDATE);
  		iota.setFloati(FLOAT_UPDATE);
  		iota.setLongi(LONG_UPDATE);
  		iota.setString(STRING_UPDATE);
  		iota.setText(TEXT_UPDATE);
  		
  		alpha.setInteger(INTEGER_UPDATE);
  		alpha.setBool(BOOLEAN_UPDATE);
  		alpha.setDecimal(DECIMAL_UPDATE);
  		alpha.setDoubli(DOUBLE_UPDATE);
  		alpha.setFloati(FLOAT_UPDATE);
  		alpha.setLongi(LONG_UPDATE);
  		alpha.setString(STRING_UPDATE);
  		alpha.setText(TEXT_UPDATE);
  		alpha.setDate(DATE_UPDATE);
  		
  		epsilon.setInteger(INTEGER_UPDATE);
  		epsilon.setBool(BOOLEAN_UPDATE);
  		epsilon.setDecimal(DECIMAL_UPDATE);
  		epsilon.setDoubli(DOUBLE_UPDATE);
  		epsilon.setFloati(FLOAT_UPDATE);
  		epsilon.setLongi(LONG_UPDATE);
  		epsilon.setString(STRING_UPDATE);
  		epsilon.setText(TEXT_UPDATE);
  
  		entityManager.updateEntity(iota);
  
  		iota = (Iota) entityManager.selectSingleEntity(iota);
  
  		Assert.assertTrue("The iota entity must not be null.", iota != null);
  		Assert.assertTrue("The alpha entity must not be null.", iota.getAlpha() != null);
  		Assert.assertTrue("The epsilon entity must not be null.", iota.getEpsilon() != null);
  		
  		Assert.assertTrue("The alpha entity must have same id after updating.", iota.getAlpha().getId().equals(alphaId));
  		Assert.assertTrue("The epsilon entity must have same id after updating.", iota.getEpsilon().getId().equals(epsilonId));
  		
  		Assert.assertTrue("The iota entity must have updated Integer value.", iota.getInteger().equals(INTEGER_UPDATE));
  		Assert.assertTrue("The iota entity must have updated Boolean value.", iota.getBool().equals(BOOLEAN_UPDATE));
  		Assert.assertTrue("The iota entity must have updated Decimal value.", iota.getDecimal().equals(DECIMAL_UPDATE));
  		Assert.assertTrue("The iota entity must have updated Double value.", iota.getDoubli().equals(DOUBLE_UPDATE));
  		Assert.assertTrue("The iota entity must have updated Float value.", iota.getFloati().equals(FLOAT_UPDATE));
  		Assert.assertTrue("The iota entity must have updated String value.", iota.getString().equals(STRING_UPDATE));
  		Assert.assertTrue("The iota entity must have updated Text value.", iota.getText().equals(TEXT_UPDATE));
  		
  		Assert.assertTrue("The alpha entity must have updated Integer value.", iota.getAlpha().getInteger().equals(INTEGER_UPDATE));
  		Assert.assertTrue("The alpha entity must have updated Boolean value.", iota.getAlpha().getBool().equals(BOOLEAN_UPDATE));
  		Assert.assertTrue("The alpha entity must have updated Decimal value.", iota.getAlpha().getDecimal().equals(DECIMAL_UPDATE));
  		Assert.assertTrue("The alpha entity must have updated Double value.", iota.getAlpha().getDoubli().equals(DOUBLE_UPDATE));
  		Assert.assertTrue("The alpha entity must have updated Float value.", iota.getAlpha().getFloati().equals(FLOAT_UPDATE));
  		Assert.assertTrue("The alpha entity must have updated String value.", iota.getAlpha().getString().equals(STRING_UPDATE));
  		Assert.assertTrue("The alpha entity must have updated Text value.", iota.getAlpha().getText().equals(TEXT_UPDATE));
  		Assert.assertTrue("The alpha entity must have updated Date value.", iota.getAlpha().getDate().getTime() == DATE_UPDATE.getTime());
  		
  		Assert.assertTrue("The epsilon entity must have updated Integer value.", iota.getEpsilon().getInteger().equals(INTEGER_UPDATE));
  		Assert.assertTrue("The epsilon entity must have updated Boolean value.", iota.getEpsilon().getBool().equals(BOOLEAN_UPDATE));
  		Assert.assertTrue("The epsilon entity must have updated Decimal value.", iota.getEpsilon().getDecimal().equals(DECIMAL_UPDATE));
  		Assert.assertTrue("The epsilon entity must have updated Double value.", iota.getEpsilon().getDoubli().equals(DOUBLE_UPDATE));
  		Assert.assertTrue("The epsilon entity must have updated Float value.", iota.getEpsilon().getFloati().equals(FLOAT_UPDATE));
  		Assert.assertTrue("The epsilon entity must have updated String value.", iota.getEpsilon().getString().equals(STRING_UPDATE));
  		Assert.assertTrue("The epsilon entity must have updated Text value.", iota.getEpsilon().getText().equals(TEXT_UPDATE));
  	}
  
  	@Test
  	public void testCascadeOneToOneEntityUpdate() throws Exception {
  		Alpha alpha = getAlphaEntity();
  		Gama gama = getGamaEntity();
  
  		alpha.setGama(gama);
  		entityManager.insertEntity(alpha);
  
  		Integer alphaId = alpha.getId();
  		Long gamaId = gama.getId();
  
  		Assert.assertTrue("The gama entity must have an id.", gamaId != null);
  		Assert.assertTrue("The alpha entity must have an id.", alphaId != null);
  
  		alpha.setInteger(INTEGER_UPDATE);
  		alpha.setBool(BOOLEAN_UPDATE);
  		alpha.setDecimal(DECIMAL_UPDATE);
  		alpha.setDoubli(DOUBLE_UPDATE);
  		alpha.setFloati(FLOAT_UPDATE);
  		alpha.setLongi(LONG_UPDATE);
  		alpha.setString(STRING_UPDATE);
  		alpha.setText(TEXT_UPDATE);
  		alpha.setDate(DATE_UPDATE);
  		
  		gama.setInteger(INTEGER_UPDATE);
  		gama.setBool(BOOLEAN_UPDATE);
  		gama.setDecimal(DECIMAL_UPDATE);
  		gama.setDoubli(DOUBLE_UPDATE);
  		gama.setFloati(FLOAT_UPDATE);
  		gama.setLongi(LONG_UPDATE);
  		gama.setString(STRING_UPDATE);
  		gama.setText(TEXT_UPDATE);
  
  		entityManager.updateEntity(alpha);
  
  		alpha = (Alpha) entityManager.selectSingleEntity(alpha);
  
  		Assert.assertTrue("The alpha entity must not be null.", alpha != null);
  		Assert.assertTrue("The gama entity must not be null.", alpha.getGama() != null);
  
  		Assert.assertTrue("The alpha entity must have same id after updating.", alpha.getId().equals(alphaId));
  		Assert.assertTrue("The gama entity must have same id after updating.", alpha.getGama().getId().equals(gamaId));
  
  		Assert.assertTrue("The alpha entity must have updated Integer value.", alpha.getInteger().equals(INTEGER_UPDATE));
  		Assert.assertTrue("The alpha entity must have updated Boolean value.", alpha.getBool().equals(BOOLEAN_UPDATE));
  		Assert.assertTrue("The alpha entity must have updated Decimal value.", alpha.getDecimal().equals(DECIMAL_UPDATE));
  		Assert.assertTrue("The alpha entity must have updated Double value.", alpha.getDoubli().equals(DOUBLE_UPDATE));
  		Assert.assertTrue("The alpha entity must have updated Float value.", alpha.getFloati().equals(FLOAT_UPDATE));
  		Assert.assertTrue("The alpha entity must have updated String value.", alpha.getString().equals(STRING_UPDATE));
  		Assert.assertTrue("The alpha entity must have updated Text value.", alpha.getText().equals(TEXT_UPDATE));
  		Assert.assertTrue("The alpha entity must have updated Date value.", alpha.getDate().getTime() == DATE_UPDATE.getTime());
  		
  		Assert.assertTrue("The gama entity must have updated Integer value.", alpha.getGama().getInteger().equals(INTEGER_UPDATE));
  		Assert.assertTrue("The gama entity must have updated Boolean value.", alpha.getGama().getBool().equals(BOOLEAN_UPDATE));
  		Assert.assertTrue("The gama entity must have updated Decimal value.", alpha.getGama().getDecimal().equals(DECIMAL_UPDATE));
  		Assert.assertTrue("The gama entity must have updated Double value.", alpha.getGama().getDoubli().equals(DOUBLE_UPDATE));
  		Assert.assertTrue("The gama entity must have updated Float value.", alpha.getGama().getFloati().equals(FLOAT_UPDATE));
  		Assert.assertTrue("The gama entity must have updated String value.", alpha.getGama().getString().equals(STRING_UPDATE));
  		Assert.assertTrue("The gama entity must have updated Text value.", alpha.getGama().getText().equals(TEXT_UPDATE));
  	}
  
  	@Test
  	public void testCascadeOneToManyEntityUpdate() throws Exception {
  		Alpha alpha = getAlphaEntity();
  		Beta beta = getBetaEntity();
  		Beta beta2 = getBetaEntity();
  
  		alpha.getBetas().add(beta);
  		alpha.getBetas().add(beta2);
  		entityManager.insertEntity(alpha);
  
  