Hibernate nesnelerinizde, normal tipteki (String, int, boolean..) verileriniz çağır anında dolarlar. Sizin eğer tablo ilişkilerinizden dolayı sınıfınızda başka bir sınıf referans edilmişse bu bağlı verilerin çekilmesi için iki yöntem vardır. Bunlar lazy ve eager. Eğer eager kullanırsanız, normal tipteki verileri çekerken ilişkili tablodaki verileride otomatikman çekmiş olursunuz. Lazy kullanırsanız eğer o verilere context içerisinde erişmek isterseniz, o zaman çeker.

import java.io.FileReader;
import java.io.FileWriter;
import java.io.Writer;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;

public class MAIN {

	public MAIN() {

		final String BOOKSTORE_XML = "./bookstore-jaxb.xml";
		try {
			UtilObject obje1 = new UtilObject(1 , "Eskisehir" );
			UtilObject obje2 = new UtilObject(2 , "Afyon" );
			UtilObject obje3 = new UtilObject(3 , "Kayseri" );
			UtilList list = new UtilList();
			list.getList().add(obje1);
			list.getList().add(obje2);
			list.getList().add(obje3);

			JAXBContext context = JAXBContext.newInstance(UtilList.class);
			Marshaller m = context.createMarshaller();
			m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
			m.marshal(list, System.out);

			Writer w = null;
			try {
				w = new FileWriter(BOOKSTORE_XML);
				m.marshal(list, w);
			} finally {
				try {
					w.close();
				} catch (Exception e) {
				}
			}

			System.out.println();
			System.out.println("Output from our XML File: ");
			Unmarshaller um = context.createUnmarshaller();
			UtilList bookstore2 = (UtilList) um.unmarshal(new FileReader(
					BOOKSTORE_XML));

			for (int i = 0; i < list.getList().toArray().length; i++) {
				System.out.println("Book " + (i + 1) + ": "
						+ bookstore2.getList().get(i).getId() + " from "
						+ bookstore2.getList().get(i).getAd());
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		new MAIN();
	}
}


<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<


import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement ( name = "util" )
@XmlAccessorType( XmlAccessType.PROPERTY )
public 	class UtilObject{
	private int id;
	private String ad;
	private String url;

	public UtilObject(){

	}

	public UtilObject(int id, String ad) {
		super();
		this.id = id;
		this.ad = ad;
	}

	public UtilObject(int id, String ad, String url ) {
		super();
		this.id = id;
		this.ad = ad;
		this.url = url;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getAd() {
		return ad;
	}

	public void setAd(String ad) {
		this.ad = ad;
	}

}



<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name="form")
@XmlAccessorType(XmlAccessType.FIELD)
public class UtilList {

	@XmlElementWrapper(name="utilList")
	@XmlElement(name="utils")
	List<UtilObject> list = new ArrayList<UtilObject>();

	public List<UtilObject> getList() {
		return list;
	}

	public void setList(List<UtilObject> list) {
		this.list = list;
	}
}
public static String convertMD5Value(String password) {
	String hashword = null;
	try {
		MessageDigest md5 = MessageDigest.getInstance("MD5");
		md5.update(password.getBytes());
		BigInteger hash = new BigInteger(1, md5.digest());
		hashword = hash.toString(16);
	} catch (NoSuchAlgorithmException nsae) {
		// ignore
	}
	return hashword;
}

yukarıdaki kod verdiğiniz bir stringi md5 e göre şifreleyerek size geri döndürür.
10. Ocak 2013 · Write a comment · Categories: Java · Tags:
PARAMETER EXPLANATION
YEAR Year, spelled out
YYYY 4-digit year
YYY
YY
Y
Last 3, 2, or 1 digit(s) of year.
IYY
IY
I
Last 3, 2, or 1 digit(s) of ISO year.
IYYY 4-digit year based on the ISO standard
RRRR Accepts a 2-digit year and returns a 4-digit year.
A value between 0-49 will return a 20xx year.
A value between 50-99 will return a 19xx year.
Q Quarter of year (1, 2, 3, 4; JAN-MAR = 1).
MM Month (01-12; JAN = 01).
MON Abbreviated name of month.
MONTH Name of month, padded with blanks to length of 9 characters.
RM Roman numeral month (I-XII; JAN = I).
WW Week of year (1-53) where week 1 starts on the first day of the year and continues to the seventh day of the year.
W Week of month (1-5) where week 1 starts on the first day of the month and ends on the seventh.
IW Week of year (1-52 or 1-53) based on the ISO standard.
D Day of week (1-7).
DAY Name of day.
DD Day of month (1-31).
DDD Day of year (1-366).
DY Abbreviated name of day.
J Julian day; the number of days since January 1, 4712 BC.
HH Hour of day (1-12).
HH12 Hour of day (1-12).
HH24 Hour of day (0-23).
MI Minute (0-59).
SS Second (0-59).
SSSSS Seconds past midnight (0-86399).
FF Fractional seconds. Use a value from 1 to 9 after FF to indicate the number of digits in the fractional seconds. For example, ‘FF4′.
AM, A.M., PM, or P.M. Meridian indicator
AD or A.D AD indicator
BC or B.C. BC indicator
TZD Daylight savings information. For example, ‘PST’
TZH Time zone hour.
TZM Time zone minute.
TZR Time zone region.
<strong>import </strong>java.util.*;
<strong>import </strong>java.text.*;
<strong>public class </strong>DateToString {
 <strong>public static void </strong>main(String[] args) {
 <strong>try </strong>{
 DateFormat formatter ; 
 Date date ;  
  formatter = <strong>new </strong>SimpleDateFormat("dd-MMM-yy");
  date = (Date)formatter.parse("11-June-07");  
  String s = formatter.format(date);
  System.out.println("Today is " + s);
  } <strong>catch </strong>(ParseException e)
  {System.out.println("Exception :"+e);  }  

 }
}