Java Mailing List Archive

http://www.gg3721.com/

Home » users.openjpa »

FieldStrategy found

rwheeler

2013-05-24

Replies: Find Java Web Hosting

Author LoginPost Reply
I am trying to implement a @Strategy using the FieldStrategy interface. The
problem I am having is that when I go to persist my object it is always
going with the default handlers. I am not receiving any exceptions until it
goes to do the insert. I am wondering if I have done this correctly or not
so any feedback is appreciated.

  package test.openjpa.entity;

  import java.io.Serializable;
  import java.util.UUID;
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.Id;
  import javax.persistence.PrePersist;
  import org.apache.openjpa.persistence.jdbc.Strategy;

  @Entity
  public class Company implements Serializable  {
 /**
  *
  */
 private static final long serialVersionUID = 6741913908217906576L;
 
 @Id
 @Strategy("test.openjpa.entity.OpenUuid")
 protected UUID id;
 
 @Column(name="name")
 private String companyName;

 public String getCompanyName() {
   return companyName;
 }

 public void setCompanyName(String companyName) {
   this.companyName = companyName;
 }
 

 @Override
 public String toString() {
   StringBuilder sb = new StringBuilder();
   sb.append("Id = ").append(id).append(" - ");
   sb.append("Name = ").append(companyName);
   return sb.toString();
 }

 
 public UUID getId() {
   return id;
 }
 public void setId(UUID id) {
   this.id = id;
 }
 @PrePersist
 public void assignUUID(){
   this.setId(UUID.randomUUID());
 }
  }

  package test.openjpa.entity;

  import java.sql.SQLException;
  import java.util.UUID;
  import org.apache.openjpa.jdbc.kernel.JDBCFetchConfiguration;
  import org.apache.openjpa.jdbc.kernel.JDBCStore;
  import org.apache.openjpa.jdbc.meta.FieldMapping;
  import org.apache.openjpa.jdbc.meta.FieldStrategy;
  import org.apache.openjpa.jdbc.sql.Joins;
  import org.apache.openjpa.jdbc.sql.Result;
  import org.apache.openjpa.jdbc.sql.RowManager;
  import org.apache.openjpa.jdbc.sql.SQLBuffer;
  import org.apache.openjpa.jdbc.sql.Select;
  import org.apache.openjpa.jdbc.sql.SelectExecutor;
  import org.apache.openjpa.kernel.OpenJPAStateManager;
  import org.apache.openjpa.persistence.jdbc.Strategy;


  public class OpenUuid implements FieldStrategy {

 /**
  *
  */
 private static final long serialVersionUID = -7313412704454986736L;


 public class PostgresUuid extends org.postgresql.util.PGobject {
   public static final long serialVersionUID = 89469482L;

   public PostgresUuid(UUID u) throws java.sql.SQLException {
     super();
     this.setType("uuid");
     this.setValue(u.toString());
   }

   public PostgresUuid() throws java.sql.SQLException {
     super();
     this.setType("uuid");
     this.setValue(null);
   }
 }

 @Override
 public String getAlias() {
   // TODO Auto-generated method stub
   return null;
 }

 @Override
 public void map(boolean adapt) {
   // TODO Auto-generated method stub

 }

 @Override
 public void initialize() {
   // TODO Auto-generated method stub

 }

 @Override
 public void insert(OpenJPAStateManager sm, JDBCStore store, RowManager rm)
throws SQLException {
   System.out.println("I am inside the insert");

 }

 @Override
 public void update(OpenJPAStateManager sm, JDBCStore store, RowManager rm)
throws SQLException {
   // TODO Auto-generated method stub

 }

 @Override
 public void delete(OpenJPAStateManager sm, JDBCStore store, RowManager rm)
throws SQLException {
   // TODO Auto-generated method stub

 }

 @Override
 public Boolean isCustomInsert(OpenJPAStateManager sm, JDBCStore store) {
   System.out.println("I am inside the isCustominsert");
   return true;
 }

 @Override
 public Boolean isCustomUpdate(OpenJPAStateManager sm, JDBCStore store) {
   // TODO Auto-generated method stub
   return null;
 }

 @Override
 public Boolean isCustomDelete(OpenJPAStateManager sm, JDBCStore store) {
   // TODO Auto-generated method stub
   return null;
 }

 @Override
 public void customInsert(OpenJPAStateManager sm, JDBCStore store) throws
SQLException {
   System.out.println("I am inside the custominsert");

 }

 @Override
 public void customUpdate(OpenJPAStateManager sm, JDBCStore store) throws
SQLException {
   // TODO Auto-generated method stub

 }

 @Override
 public void customDelete(OpenJPAStateManager sm, JDBCStore store) throws
SQLException {
   // TODO Auto-generated method stub

 }

 @Override
 public void setFieldMapping(FieldMapping owner) {
   System.out.println("I am inside the FieldMapping");

 }

 @Override
 public int supportsSelect(Select sel, int type, OpenJPAStateManager sm,
JDBCStore store,
     JDBCFetchConfiguration fetch) {
   // TODO Auto-generated method stub
   return 0;
 }

 @Override
 public void selectEagerParallel(SelectExecutor sel, OpenJPAStateManager sm,
JDBCStore store,
     JDBCFetchConfiguration fetch, int eagerMode) {
   // TODO Auto-generated method stub

 }

 @Override
 public void selectEagerJoin(Select sel, OpenJPAStateManager sm, JDBCStore
store, JDBCFetchConfiguration fetch,
     int eagerMode) {
   // TODO Auto-generated method stub

 }

 @Override
 public boolean isEagerSelectToMany() {
   // TODO Auto-generated method stub
   return false;
 }

 @Override
 public int select(Select sel, OpenJPAStateManager sm, JDBCStore store,
JDBCFetchConfiguration fetch, int eagerMode) {
   // TODO Auto-generated method stub
   return 0;
 }

 @Override
 public Object loadEagerParallel(OpenJPAStateManager sm, JDBCStore store,
JDBCFetchConfiguration fetch, Object res)
     throws SQLException {
   // TODO Auto-generated method stub
   return null;
 }

 @Override
 public void loadEagerJoin(OpenJPAStateManager sm, JDBCStore store,
JDBCFetchConfiguration fetch, Result res)
     throws SQLException {
   // TODO Auto-generated method stub

 }

 @Override
 public void load(OpenJPAStateManager sm, JDBCStore store,
JDBCFetchConfiguration fetch, Result res)
     throws SQLException {
   // TODO Auto-generated method stub

 }

 @Override
 public void load(OpenJPAStateManager sm, JDBCStore store,
JDBCFetchConfiguration fetch) throws SQLException {
   // TODO Auto-generated method stub

 }

 @Override
 public Object toDataStoreValue(Object val, JDBCStore store) {
   System.out.println("I am inside the toDataStoreValue");
   return null;
 }

 @Override
 public Object toKeyDataStoreValue(Object val, JDBCStore store) {
   System.out.println("I am inside the toKeyDataStoreValue");
   return null;
 }

 @Override
 public void appendIsEmpty(SQLBuffer sql, Select sel, Joins joins) {
   System.out.println("I am inside the appendIsEmpty");

 }

 @Override
 public void appendIsNotEmpty(SQLBuffer sql, Select sel, Joins joins) {
   System.out.println("I am inside the appendIsNotEmpty");

 }

 @Override
 public void appendIsNull(SQLBuffer sql, Select sel, Joins joins) {
   System.out.println("I am inside the appendIsNull");

 }

 @Override
 public void appendIsNotNull(SQLBuffer sql, Select sel, Joins joins) {
   System.out.println("I am inside the appendIsNotNull");

 }

 @Override
 public void appendSize(SQLBuffer sql, Select sel, Joins joins) {
   // TODO Auto-generated method stub

 }

 @Override
 public void appendIndex(SQLBuffer sql, Select sel, Joins joins) {
   // TODO Auto-generated method stub

 }

 @Override
 public void appendType(SQLBuffer sql, Select sel, Joins joins) {
   // TODO Auto-generated method stub

 }

 @Override
 public Joins join(Joins joins, boolean forceOuter) {
   // TODO Auto-generated method stub
   return null;
 }

 @Override
 public Joins joinKey(Joins joins, boolean forceOuter) {
   // TODO Auto-generated method stub
   return null;
 }

 @Override
 public Joins joinRelation(Joins joins, boolean forceOuter, boolean
traverse) {
   // TODO Auto-generated method stub
   return null;
 }

 @Override
 public Joins joinKeyRelation(Joins joins, boolean forceOuter, boolean
traverse) {
   // TODO Auto-generated method stub
   return null;
 }

 @Override
 public Object loadProjection(JDBCStore store, JDBCFetchConfiguration fetch,
Result res, Joins joins)
     throws SQLException {
   // TODO Auto-generated method stub
   return null;
 }

 @Override
 public Object loadKeyProjection(JDBCStore store, JDBCFetchConfiguration
fetch, Result res, Joins joins)
     throws SQLException {
   // TODO Auto-generated method stub
   return null;
 }

 @Override
 public boolean isVersionable() {
   System.out.println("I am inside the isVersionable");
   return false;
 }

 @Override
 public void where(OpenJPAStateManager sm, JDBCStore store, RowManager rm,
Object prevValue) throws SQLException {
   // TODO Auto-generated method stub

 }

  }



--
Sent from the OpenJPA Users mailing list archive at Nabble.com.
©2008 gg3721.com - Jax Systems, LLC, U.S.A.