abstractbookfactory.java

来自「OR Mapping工具」· Java 代码 · 共 174 行

JAVA
174
字号
package org.ephman.junit.generated;import java.sql.*;import org.ephman.abra.utils.*;import org.ephman.abra.database.*;// Do not edit!! generated classes /** a factory to link the class Book * to it's sql code and database table * @version Thu Jun 30 15:12:42 EDT 2005 * @author generated by Dave Knull */public abstract class AbstractBookFactory extends FactoryBase{/** this method returns the update string for the db */	protected String makeUpdateString () {		return updateString;	}	protected static final String updateString = "update db_book set " +		"version_number = ?," +		"b_title = ?," +		"b_text = ?," +		"b_publisher = ?," +		"b_author = ?," +		"b_isbn = ? where b_oid = ?";/** this method returns the insert string for the db */	protected String makeInsertString () {		return insertString;	}	protected static final String insertString = "insert into db_book (" +		"version_number," +		"b_title," +		"b_text," +		"b_publisher," +		"b_author," +		"b_isbn) values (" +		" ?," +		" ?," +		" ?," +		" ?," +		" ?," +		" ?)";/** this method sets the args for a prepared statement */	protected void setArguments (PreparedStatement stmt, Object obj, boolean update) throws SQLException {		Book book = (Book)obj;		int i = 1;		if (!update && useStoredProcs ()) // set return val..			((CallableStatement)stmt).registerOutParameter (i++, Types.INTEGER);		stmt.setInt (i++, book.getVersion ());		stmt.setString (i++, book.getTitle ());		stmt.setString (i++, book.getText ());		if (book.getPublisher() == null) {			if (book.getPublisherOid () == 0)				stmt.setNull (i++, java.sql.Types.INTEGER);			else				stmt.setInt (i++, book.getPublisherOid ());		} else			stmt.setInt (i++, book.getPublisher ().getOid ());		if (book.getAuthor() == null) {			if (book.getAuthorOid () == 0)				stmt.setNull (i++, java.sql.Types.INTEGER);			else				stmt.setInt (i++, book.getAuthorOid ());		} else			stmt.setInt (i++, book.getAuthor ().getOid ());		stmt.setString (i++, book.getIsbn ());		if (update)			stmt.setInt (i++, book.getOid ());	}/** this method tells FactoryBase whether or not clobs exist */	protected boolean hasClobs () { return false; }	protected String makeInsertCall () {		return insertCallString;	}	public static final String insertCallString = "{? = call FUNC_INS_Book(?,?,?,?,?,?) }";	public static final String updateCallString = "{ call PROC_UPD_Book(?,?,?,?,?,?,?) }";	protected String makeUpdateCall () {		return updateCallString;	}	protected boolean useStoredProcs () { return false; }	// methods to store and delete	public void delete (DatabaseSession dbSess, Book foo) throws SQLException {		super.deleteObject (dbSess, foo);	}	public void store (DatabaseSession dbSess, Book foo) throws SQLException {		super.storeObject (dbSess, foo);	}	/* a routine to build an object of this type from an sql ResultSet */	protected Identified makeFromResultSet (ResultSet rs) throws SQLException{		Book foo = new Book ();		refreshFromResultSet (foo, rs);		return foo;	}	/* a routine to overwrite an object of this type from an sql ResultSet */	protected void refreshFromResultSet (Identified item, ResultSet rs) throws SQLException{		Book foo = (Book)item;		foo.setVersion (rs.getInt(version_number));		foo.setTitle (rs.getString (title));		foo.setText (rs.getString (text));		foo.setPublisherOid (rs.getInt (publisherOid));		foo.setOid (rs.getInt (oid));		foo.setAuthorOid (rs.getInt (authorOid));		foo.setIsbn (rs.getString (Isbn));	}	public String makeEditLookupString () {		String result = "select "			+ "this.b_title"			+ " from db_book this"			+ " where ";		return result;	}	public org.ephman.junit.generated.EditBook makeEditFromResultSet (ResultSet rs) throws SQLException {		org.ephman.junit.generated.EditBook foo = new org.ephman.junit.generated.EditBook ();		foo.setTitle (rs.getString (title));		return foo;	}	public ViewLookup editLookup;	public Book getByOid (DatabaseSession dbSess, int object_id) throws SQLException {		return (Book)super.getObject (dbSess, this.oid, object_id);	}	public String getPrimaryColumn () { return "b_oid"; }	public String getTableName () { return tableName; }	// the variables to map Java to Sql	protected final String tableName = "db_book";	public final String title = "b_title";	public final String text = "b_text";	public final String publisherOid = "b_publisher";	public final String oid = "b_oid";	public final String authorOid = "b_author";	public final String Isbn = "b_isbn";	public final String version_number = "version_number";	protected AbstractBookFactory () {		super ();		editLookup = new ViewLookup (makeEditLookupString (),				"makeEditFromResultSet", 				this);	}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?