Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 27691 Details for
Bug 111014
Internal Compiler Error
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
This is the other file involved in the test case
XDAO.java (text/plain), 11.90 KB, created by
Roberto Leibman
on 2005-09-29 14:22:04 EDT
(
hide
)
Description:
This is the other file involved in the test case
Filename:
MIME Type:
Creator:
Roberto Leibman
Created:
2005-09-29 14:22:04 EDT
Size:
11.90 KB
patch
obsolete
>/* > * Copyright �© 2005 Freezlets, Inc > * > * Last Change : $Author: roberto $ > * File Id : $Id: XDAO.java,v 1.2 2005/04/07 22:17:50 roberto Exp $ > * > * Accessing, using, copying, modifying or distributing this source code is > * expressly not permitted without the prior written authorization of > * Freezlets, Inc. > * > * Engaging in any such activities without such authorization is an infringhment > * of Freezlets Inc. copyrights and a misappropriation of Freezlets Inc > * trade secrets in this source code, which will subject the perpetrator to > * certain civil damages and criminal penalties > * > */ >package com.freezlets.dao; > >import java.security.Principal; >import java.sql.PreparedStatement; >import java.sql.ResultSet; >import java.sql.SQLException; >import java.util.ArrayList; >import java.util.Collection; >import java.util.Iterator; > >import com.freezlets.FreezletsException; >import com.freezlets.business.PrimaryKey; >import com.freezlets.business.ValueObject; >import com.freezlets.security.PermissionException; >import com.freezlets.util.Log; > >/** > * @author leibmar > * @version > */ >public abstract class XDAO extends DAOImpl >{ > public abstract String[] getOneForeignKeyColumnNames(); > > public abstract String[] getManyForeignKeyColumnNames(); > > protected DAOImpl oneDAO; > > protected DAOImpl manyDAO; > > /** > * Creates new XDAO > * > * @param oneDAO > * document: this Parameter > * @param manyDAO > * document: this Parameter > */ > public XDAO(DAOImpl oneDAO, DAOImpl manyDAO) > { > this.oneDAO = oneDAO; > this.manyDAO = manyDAO; > } > > /** > * Gets the joinCriteria attribute of the XDAO object > * > * @return The joinCriteria value > */ > protected abstract String getJoinClause(); > > /** > * document: this method > * > * @param onePK > * document: this Parameter > * @param criteria > * document: this Parameter > * @return document: this Return Value > * @throws DAOException > * @throws FreezletsException > * @throws PermissionException > * @exception JCPSSException > * document: this the Exception > */ > public Collection find(PrimaryKey onePK, Criteria criteria, Principal principal) > throws DAOException, PermissionException, FreezletsException > { > DAOTransaction transaction = new DAOTransaction(true); > > try > { > return find(onePK, criteria, transaction, principal); > } > finally > { > if (transaction != null) > transaction.close(); > } > } > > public PrimaryKey store(ValueObject one, ValueObject many, ValueObject object, > DAOTransaction transaction, Principal principal) throws FreezletsException, DAOException, PermissionException > { > PreparedStatement stmt = null; > ResultSet rs = null; > > try > { > String sql; > boolean exists = false; > > PrimaryKey pk = new PK(one.getPrimaryKey(), many.getPrimaryKey()); > > StringBuffer buff = new StringBuffer(); > Criteria criteria = getPrimaryKeyCriteria(pk); > buff.append("select count(*) as theCount from ").append(getTableName()).append( > " WHERE ").append(criteria.getWhereClause()); > sql = buff.toString(); > Log.instance("sql").debug(sql); > stmt = transaction.getConnection().prepareStatement(sql); > int index = 1; > setValues(index, criteria, stmt); > > rs = stmt.executeQuery(); > rs.next(); > exists = rs.getInt("theCount") > 0; > > String primaryKeyColumnNames[] = getPrimaryKeyColumnNames(); > String columnNames[] = getColumnNames(); > > if (exists) > { > //update > buff.setLength(0); > buff.append("update ").append(getTableName()).append(" set "); > for (int i = 0; i < columnNames.length; ++i) > { > buff.append(columnNames[i]).append(" = ?"); > if (i < (columnNames.length - 1)) > { > buff.append(", "); > } > } > buff.append(" where ").append(criteria.getWhereClause()); > > sql = buff.toString(); > Log.instance("sql").debug(sql); > > stmt = transaction.getConnection().prepareStatement(sql); > index = 1; > index = setValues(index, object, stmt); > index = setValues(index, criteria, stmt); > stmt.execute(); > > DAOUpdateEvent event = new DAOUpdateEvent(principal, object, pk, transaction); > for (Iterator iter = updateListeners.iterator(); iter.hasNext();) > { > DAOUpdateListener element = (DAOUpdateListener) iter.next(); > element.handleEvent(event); > } > } > else > { > //insert > buff.setLength(0); > buff.append("insert into ").append(getTableName()).append(" ("); > > for (int i = 0; i < columnNames.length; ++i) > { > buff.append(columnNames[i]); > buff.append(", "); > } > for (int i = 0; i < primaryKeyColumnNames.length; ++i) > { > buff.append(primaryKeyColumnNames[i]); > if (i < (primaryKeyColumnNames.length - 1)) > { > buff.append(", "); > } > } > buff.append(") values ("); > for (int i = 0; i < columnNames.length; ++i) > { > buff.append("?, "); > } > for (int i = 0; i < primaryKeyColumnNames.length; ++i) > { > buff.append("?"); > if (i < (primaryKeyColumnNames.length - 1)) > { > buff.append(", "); > } > } > buff.append(")"); > > sql = buff.toString(); > Log.instance("sql").debug(sql); > stmt = transaction.getConnection().prepareStatement(sql); > index = 1; > index = setValues(index, object, stmt); > index = setValues(index, pk, stmt); > > stmt.execute(); > > DAOCreateEvent event = new DAOCreateEvent(principal, object, pk, transaction); > for (Iterator iter = createListeners.iterator(); iter.hasNext();) > { > DAOCreateListener element = (DAOCreateListener) iter.next(); > element.handleEvent(event); > } > } > Log.instance().info("Key = " + pk); > return pk; > } > catch (SQLException e) > { > Log.instance().error(e); > throw new DAOException("Error Creating X Object: " + object.toString() + ": " > + e.getMessage(), e); > } > finally > { > try > { > if (rs != null) > { > rs.close(); > } > } > catch (SQLException ee) > { > com.freezlets.util.Log.instance().debug("Exception swallowed: " + ee); > } > try > { > if (stmt != null) > { > stmt.close(); > } > } > catch (SQLException ee) > { > com.freezlets.util.Log.instance().debug("Exception swallowed: " + ee); > } > } > } > > public PrimaryKey store(ValueObject one, ValueObject many, ValueObject object, > Principal principal) throws DAOException, PermissionException, FreezletsException > { > DAOTransaction transaction = new DAOTransaction(true); > > try > { > return store(one, many, object, transaction, principal); > } > finally > { > if (transaction != null) > transaction.close(); > } > } > > /** > * document: this method > * > * @param onePK > * document: this Parameter > * @param criteria > * document: this Parameter > * @param transaction > * document: this Parameter > * @return document: this Return Value > * @exception FreezletsException > * document: this the Exception > * @throws DAOException > * @throws PermissionException > */ > public Collection find(PrimaryKey onePK, Criteria criteria, DAOTransaction transaction, > Principal principal) throws FreezletsException, DAOException, PermissionException > { > PreparedStatement stmt = null; > ResultSet rs = null; > String sql = ""; > > try > { > StringBuffer buff = new StringBuffer("select "); > > for (int i = 0; i < getPrimaryKeyColumnNames().length; ++i) > { > buff.append(getPrimaryKeyColumnNames()[i]); > if (manyDAO.getColumnNames().length != 0) > { > buff.append(", "); > } > } > for (int i = 0; i < manyDAO.getPrimaryKeyColumnNames().length; ++i) > { > buff.append(manyDAO.getTableName()).append(".").append( > manyDAO.getPrimaryKeyColumnNames()[i]); > if (manyDAO.getPrimaryKeyColumnNames().length != 0 > || i < (getPrimaryKeyColumnNames().length - 1)) > { > buff.append(", "); > } > } > for (int i = 0; i < manyDAO.getColumnNames().length; ++i) > { > buff.append(manyDAO.getColumnNames()[i]); > if (i < (manyDAO.getColumnNames().length - 1)) > { > buff.append(", "); > } > } > Criteria primaryKeyCriteria = getOnePrimaryKeyCriteria(onePK); > buff.append(" from ").append(manyDAO.getTableName()).append(" ") > .append(getJoinClause()).append(" ").append(" WHERE ").append( > primaryKeyCriteria.getWhereClause()); > if (criteria != null && criteria.getWhereClause().length() > 0) > { > buff.append(" AND ").append(criteria.getWhereClause()); > } > if (criteria != null && criteria.getOrderByClause().length() > 0) > { > buff.append(" ORDER BY ").append(criteria.getOrderByClause()); > } > sql = buff.toString(); > > stmt = transaction.getConnection().prepareStatement(sql); > int index = 1; > index = setValues(index, primaryKeyCriteria, stmt); > index = setValues(index, criteria, stmt); > > Log.instance("sql").debug(sql); > > ArrayList list = new ArrayList(); > > rs = stmt.executeQuery(); > while (rs.next()) > { > ValueObject obj = manyDAO.valueObjectFactory(rs); > obj.setPrimaryKey(manyDAO.primaryKeyFactory(rs)); > manyDAO.loadAssociates(obj, transaction, principal); > list.add(obj); > > } > return list; > } > catch (SQLException e) > { > throw new DAOException("Error performing query: '" + sql + "': " + e.getMessage(), e); > } > finally > { > try > { > if (rs != null) > { > rs.close(); > } > } > catch (SQLException ee) > { > com.freezlets.util.Log.instance().debug("Exception swallowed: " + ee); > } > try > { > if (stmt != null) > { > stmt.close(); > } > } > catch (SQLException ee) > { > com.freezlets.util.Log.instance().debug("Exception swallowed: " + ee); > } > } > } > > /** > * @param onePK > * @return > */ > protected Criteria getOnePrimaryKeyCriteria(PrimaryKey onePK) > { > return oneDAO.getPrimaryKeyCriteria(onePK); > } > > public static class PK implements com.freezlets.business.PrimaryKey > { > public PrimaryKey onePK; > > public PrimaryKey manyPK; > > public PK(PrimaryKey onePK, PrimaryKey manyPK) > { > this.onePK = onePK; > this.manyPK = manyPK; > } > > public boolean equals(Object otherKey) > { > if (otherKey == this) > { > return true; > } > if ((otherKey == null) || !(otherKey instanceof PK)) > { > return false; > } > return onePK.equals(((PK) otherKey).onePK) && manyPK.equals(((PK) otherKey).manyPK); > } > > public int hashCode() > { > return onePK.hashCode() + (manyPK.hashCode() << 16); > } > } > > /** > * Gets the primaryKeyColumnValues attribute of the DAO object > * > * @param pk > * document: this Parameter > * @return The primaryKeyColumnValues value > */ > public Object[] getPrimaryKeyColumnValues(PrimaryKey ppk) > { > assert (getOneForeignKeyColumnNames().length == oneDAO.getColumnNames().length); > assert (getManyForeignKeyColumnNames().length == manyDAO.getColumnNames().length); > > PK pk = (PK) ppk; > Object allPrimaryKeyColumnValues[] = new Object[getOneForeignKeyColumnNames().length > + getManyForeignKeyColumnNames().length]; > Object oneValues[] = oneDAO.getPrimaryKeyColumnValues(pk.onePK); > Object manyValues[] = manyDAO.getPrimaryKeyColumnValues(pk.manyPK); > int j = 0; > for (int i = 0; i < oneValues.length; ++i, ++j) > { > allPrimaryKeyColumnValues[j] = oneValues[i]; > } > for (int i = 0; i < manyValues.length; ++i, ++j) > { > allPrimaryKeyColumnValues[j] = manyValues[i]; > } > return allPrimaryKeyColumnValues; > } > > /** > * Gets the primaryKeyColumnNames attribute of the DAO object > * > * @return The primaryKeyColumnNames value > */ > public String[] getPrimaryKeyColumnNames() > { > assert (getOneForeignKeyColumnNames().length == oneDAO.getColumnNames().length); > assert (getManyForeignKeyColumnNames().length == manyDAO.getColumnNames().length); > > String allPrimaryKeyColumnNames[]; > allPrimaryKeyColumnNames = new String[getOneForeignKeyColumnNames().length > + getManyForeignKeyColumnNames().length]; > int j = 0; > for (int i = 0; i < getOneForeignKeyColumnNames().length; ++i, ++j) > { > allPrimaryKeyColumnNames[j] = getOneForeignKeyColumnNames()[i]; > } > for (int i = 0; i < getManyForeignKeyColumnNames().length; ++i, ++j) > { > allPrimaryKeyColumnNames[j] = getManyForeignKeyColumnNames()[i]; > } > return allPrimaryKeyColumnNames; > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 111014
:
27690
| 27691