View source
From RCUB
for
Osnove JPA
Jump to:
navigation
,
search
Implementacije: * Apache OpenJPA * Hibernate EntityManager * Oracle TopLink Essentials Uputstvo: http://openjpa.apache.org/builds/1.2.1/apache-openjpa-1.2.1/docs/manual/manual.html Primer POJO klase sa anotacijama: <pre> @Entity @Table(name="test_table") public class TestTable implements Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name="id") private int id; @Column(name="int_field") private int integerField; @Column(name="string_field") private String stringField; private static final long serialVersionUID = 1L; public TestTable() { } public int getId() { return id; } public void setId(int id) { this.id = id; } public int getIntegerField() { return this.integerField; } public void setIntegerField(int integerField) { this.integerField = integerField; } public String getStringField() { return this.stringField; } public void setStringField(String stringField) { this.stringField = stringField; } } </pre> Primer persistence.xml fajla: <pre> <?xml version="1.0" encoding="UTF-8"?> <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"> <persistence-unit name="eTestPu"> <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider> <class>model.TestTable</class> <properties> <property name="openjpa.ConnectionURL" value="jdbc:mysql://server.rcub.bg.ac.rs/baza?useUnicode=true&characterEncoding=utf-8"/> <property name="openjpa.ConnectionDriverName" value="com.mysql.jdbc.Driver"/> <property name="openjpa.ConnectionUserName" value="ognjen"/> <property name="openjpa.ConnectionPassword" value="lozinka"/> <property name="openjpa.jdbc.DBDictionary" value="SupportsSubselect=true"/> </properties> </persistence-unit> </persistence> </pre> Primer orm.xml fajla: <pre> <?xml version="1.0" encoding="UTF-8" ?> <entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm http://java.sun.com/xml/ns/persistence/orm_1_0.xsd" version="1.0"> <named-query name="TestTable.findAll"> <query> select o from TestTable o </query> </named-query> </entity-mappings> </pre>
Return to
Osnove JPA
.
Personal tools
Log in
Namespaces
Page
Discussion
Variants
Views
Read
View source
View history
Actions
Search
Navigation
Main page
Community portal
Current events
Recent changes
Random page
Help
Toolbox
What links here
Related changes
Special pages