Eclipse De Jpa
Eclipse¤ÇJPA¥×¥í¥¸¥§¥¯¥È¤òºîÀ®¤Ç¤¤Þ¤¹¡£
[¥Õ¥¡¥¤¥ë]¢ª[¿·µ¬]¢ª[¤½¤Î¾]
¤òÁªÂò¸å¡¢[JPA]¢ª[JPA¥×¥í¥¸¥§¥¯¥È]¤òÁªÂò¤·¤Þ¤¹¡£
#ÏäÏÌá¤ê¤Þ¤¹¤¬¡¢
#JPA¤òư¤«¤¹¤Ë¤Ï"EclipseLink1.x"¡¢"OpenJPA"¡¢"Hibernate"¤Ê¤É¤ÎJPA¥×¥í¥Ð¥¤¥À¡¼¤¬É¬ÍפǤ¹¡£
#¸Ä¿ÍŪ¤Ï"OpenJPA"¤¬¤¤¤¤¤Ç¤¹¤Í¡Ê¤Ê¤ó¤È¤Ê¤¯¤Ç¤¹¡Ë
#¤Ê¤Î¤Ç¡¢JPA¤ò»È¤¦¤Ë¤Ï¤Þ¤º¤¤¤º¤ì¤«¤ÎJar¥Õ¥¡¥¤¥ë¤¬É¬Íפˤʤê¤Þ¤¹¡£
#"EclipseLink1.x"¤ÏEclipse Galileo¤Çɸ½à¤Ç¤¹
JPA¥×¥í¥¸¥§¥¯¥È¤òºîÀ®¤¹¤ë¤¿¤á¤Ë¥¦¥£¥¶¡¼¥É¤Ë½¾¤Ã¤Æ´ö¤Ä¤«¤Î¾ðÊó¤òÆþÎϤ·¤Þ¤¹¡£
¥×¥í¥¸¥§¥¯¥ÈºîÀ®¸å¡¢¥Ç¡¼¥¿¥Ù¡¼¥¹¤òÍѰդ·¤Þ¤·¤ç¤¦¡£
JPA¤ÎÀßÄê¥Õ¥¡¥¤¥ë(persistence.xml)¤ò½¤Àµ¤·¤Þ¤¹¡£Ä̾ïMETA-INF¤Ë¤¢¤ê¤Þ¤¹¡£
°Ê²¼¤Ï"Eclipselink"ÍѤǤ¹¡£
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="̾Á°¤ò¤Ä¤±¤Þ¤¹" transaction-type="RESOURCE_LOCAL">
<description>ÀâÌÀ¤ò½ñ¤¤Þ¤¹</description>
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<mapping-file>META-INF/orm.xml</mapping-file>
<properties>
<property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.oracle.OraclePlatform"/>
<property name="eclipselink.jdbc.url" value="jdbc:oracle:thin:@URL:¥Ý¡¼¥È:ORCL"/>
<property name="eclipselink.jdbc.user" value="hoge"/>
<property name="eclipselink.jdbc.password" value="pwd"/>
<property name="eclipselink.jdbc.driver" value="oracle.jdbc.driver.OracleDriver"/>
<property name="eclipselink.logging.level" value="FINE" />
<property name="eclipselink.weaving" value="false"/>
</properties>
</persistence-unit>
</persistence>
°Ê²¼¤Ï"OpenJPA"ÍѤǤ¹¡£
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="sample.test.jpa" transaction-type="RESOURCE_LOCAL">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<non-jta-data-source>dataSource</non-jta-data-source>
<mapping-file>META-INF/orm.xml</mapping-file>
<properties>
<property name="openjpa.ConnectionUserName" value="hoge"/>
<property name="openjpa.ConnectionPassword" value="pwd"/>
<property name="openjpa.ConnectionURL" value="jdbc:oracle:thin:@URL:¥Ý¡¼¥È:XE"/>
<property name="openjpa.ConnectionDriverName" value="oracle.jdbc.OracleDriver"/>
<property name="openjpa.ConnectionFactoryProperties" value="PrettyPrint=true, PrettyPrintLineLength=80"/>
<property name="openjpa.Log" value="DefaultLevel=INFO,SQL=TRACE"/>
</properties>
</persistence-unit>
</persistence>
¼¡¤Ë¡¢¥×¥í¥¸¥§¥¯¥È̾¤ò±¦¥¯¥ê¥Ã¥¯¤ÇÁªÂò¸å¡¢[JPA ¥Ä¡¼¥ë]¢ª[¥Æ¡¼¥Ö¥ë¤«¤é¥¨¥ó¥Æ¥£¥Æ¥£¡¼¤òÀ¸À®]¤òÁª¤Ó¡¢¥¦¥£¥¶¡¼¥É¤Ë½¾¤¤¤Þ¤¹¡£
´°Î»¸å¡¢¥Æ¡¼¥Ö¥ë̾¤Î¥¯¥é¥¹¥Õ¥¡¥¤¥ë¤¬¼«Æ°À¸À®¤µ¤ì¤Æ¤¤¤ë¤Ï¤º¤Ç¤¹¡£
¤Ç»ÈÍÑÊýË¡¤Ï¤³¤ó¤Ê´¶¤¸¤Ç¤¹
EntityManagerFactory emf = Persistence.createEntityManagerFactory("Persistence.xml¤Ç¤Ä¤±¤¿Ì¾Á°");
EntityManager em = emf.createEntityManager();
¼«Æ°À¸À®¤µ¤ì¤¿¥¨¥ó¥Æ¥£¥Æ¥£¡¼¥¯¥é¥¹ ui2 = em.find(¼«Æ°À¸À®¤µ¤ì¤¿¥¨¥ó¥Æ¥£¥Æ¥£¡¼¥¯¥é¥¹.class, 25L);