- испльзование JSF с транзакциями
- загрузка ManyToOne звязи Persistence
Показ дописів із міткою j2ee. Показати всі дописи
Показ дописів із міткою j2ee. Показати всі дописи
середа, серпня 12, 2009
Persistence fecting ManyToOne
@ManyToOne Annotation
@Target({METHOD, FIELD}) @Retention(RUNTIME)
public @interface ManyToOne {
Class targetEntity() default void.class;
CascadeType[] cascade() default {};
FetchType fetch() default EAGER;
boolean optional() default true;
}
The options for the @ManyToOne annotation have the same meanings as in the @OneToMany annotation; the only difference is the addition of the optional boolean. This defines whether the association is optional. If it is set to false, a non-null relationship must always exist.
@ManyToOne(optional=false, fetch = FetchType.EAGER)
@JoinColumn( name="topic_id" )
Additionally Annotation @OneToMany:
@OneToMany(fetch = FetchType.EAGER, cascade = {CascadeType.ALL}, mappedBy = "forumBean")
Источник:
http://www.informit.com/guides/content.aspx?g=java&seqNum=241
четвер, серпня 06, 2009
Особливості використання Toplink JPA на Tomcat
package es.claro.commons.ds;
import oracle.toplink.essentials.tools.sessionconfiguration.SessionCustomizer;
import oracle.toplink.essentials.sessions.Session;
import oracle.toplink.essentials.jndi.JNDIConnector;
public class DataSourceSessionCustomizer implements SessionCustomizer {
public DataSourceSessionCustomizer() {
}
public void customize(Session session) throws Exception {
JNDIConnector conn = (JNDIConnector)session.getLogin().getConnector();
conn.setLookupType(JNDIConnector.STRING_LOOKUP);
}
}
у war "WEB-INF\classes\META-INF\persistence.xml":
<?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="SamplePU" transaction-type="RESOURCE_LOCAL">
<provider>oracle.toplink.essentials.ejb.cmp3.EntityManagerFactoryProvider</provider>
<non-jta-data-source>java:comp/env/jdbc/DefaultDS</non-jta-data-source>
<class>sample.MyEntity</class>
<properties>
<property name="toplink.session.customizer" value="es.claro.commons.ds.DataSourceSessionCustomizer"/>
</properties>
</persistence-unit>
</persistence>
Використання DataSource у програмі
у war "META-INF\context.xml":
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/sample">
<ResourceLink global="jdbc/MyRealDS" name="jdbc/DefaultDS" type="javax.sql.DataSource"/>
</Context>
Джерело:
Особливості використання Toplink JPA на Tomcat
Working with a non JTA DataSource in Toplink Essentials
понеділок, серпня 03, 2009
Tomcat TopList and connectoin pool
Using TopLink on Tomcat with connection pool
http://forums.oracle.com/forums/thread.jspa?messageID=1899677
also see (this example without connection pool):
http://www.oracle.com/technology/products/ias/toplink/jpa/tutorials/jsf-jpa-tutorial.html
http://forums.oracle.com/forums/thread.jspa?messageID=1899677
also see (this example without connection pool):
http://www.oracle.com/technology/products/ias/toplink/jpa/tutorials/jsf-jpa-tutorial.html
Підписатися на:
Дописи (Atom)
+01-12-07_2230_3.jpg)