[s2container-php5:101] findAllArrayメソッド実行時にS2Dao_PrimaryKeyNotFoundRuntimeException発生。(長文)
Yoshinari Ueyama
[E-MAIL ADDRESS DELETED]
2007年 8月 8日 (水) 01:32:54 JST
うえやまです。
最近、ひさしぶりにS2Daoでプログラムを作成しだしました。
で、あるテーブル用のDaoとEntityを作成してDaoのfindAllArrayを
実行すると以下のエラーが発生しました。
どうも、s2dao.core.classes.phpのcheckPrimaryKey()実行時にPKが
定義されていないと判断されてエラーとなっているようです。
create table文を見る限りPK設定していますし・・・
これから調べていくつもりですが、過去に同じようなことが起こったなど
参考になるような情報がありましたら教えていただけないでしょうか?
テーブル定義が正しい(PK定義済み)として、$bmd->getPrimaryKeySize() == 0となる状況は
どのような不具合が想定されるでしょうか??
以上です。何らかの対応をしていただけたらありがたいです。
S2ContainerおよびS2Daoは最新を使用しています。
--------------------------------以下、参考情報-------------
1.発生したエラー
S2Dao_PrimaryKeyNotFoundRuntimeException
Description
PrimaryKey not found in UsersEntity
Source File
/Users/webadmin/lib/S2Dao/build/s2dao.php5/s2dao.core.classes.php (933)
0922: protected function setupDeleteSql() {
0923: $this->checkPrimaryKey();
0924: $buf = '';
0925: $buf .= 'DELETE FROM ';
0926: $buf .= $this->getBeanMetaData()->getTableName();
0927: $this->setupUpdateWhere($buf);
0928: $this->setSql($buf);
0929: }
0930: protected function checkPrimaryKey() {
0931: $bmd = $this->getBeanMetaData();
0932: if ($bmd->getPrimaryKeySize() == 0) {
0933: throw new
S2Dao_PrimaryKeyNotFoundRuntimeException($bmd->getBeanClass());
0934: }
0935: }
0936: protected function setupUpdateWhere(&$buf) {
0937: $bmd = $this->getBeanMetaData();
0938: $buf .= ' WHERE ';
0939: for ($i = 0; $i < $bmd->getPrimaryKeySize(); ++$i) {
0940: $buf .= $bmd->getPrimaryKey($i);
0941: $buf .= ' = ? AND ';
0942: }
0943: $buf = preg_replace('/( AND )$/', '', $buf);
0944: if ($bmd->hasVersionNoPropertyType()) {
0945: $pt = $bmd->getVersionNoPropertyType();
Stack Trace
#0 /Users/webadmin/lib/S2Dao/build/s2dao.php5/s2dao.core.classes.php(907):
S2Dao_AbstractAutoStaticCommand->checkPrimaryKey()
#1
/Users/webadmin/lib/S2Dao/build/s2dao.php5/S2Dao/S2Dao_UpdateAutoStaticCommand.class.php(47):
S2Dao_AbstractAutoStaticCommand->setupUpdateSql()
#2 /Users/webadmin/lib/S2Dao/build/s2dao.php5/s2dao.core.classes.php(840):
S2Dao_UpdateAutoStaticCommand->setupSql()
#3
/Users/webadmin/lib/S2Dao/build/s2dao.php5/S2Dao/S2Dao_UpdateAutoStaticCommand.class.php(35):
S2Dao_AbstractAutoStaticCommand->__construct(Object(S2Container_PDODataSource),
Object(S2Dao_BasicStatementFactory), Object(S2Dao_BeanMetaDataImpl), Array)
#4
/Users/webadmin/lib/S2Dao/build/s2dao.php5/S2Dao/S2Dao_DaoMetaDataImpl.class.php(235):
S2Dao_UpdateAutoStaticCommand->__construct(Object(S2Container_PDODataSource),
Object(S2Dao_BasicStatementFactory), Object(S2Dao_BeanMetaDataImpl), Array)
#5
/Users/webadmin/lib/S2Dao/build/s2dao.php5/S2Dao/S2Dao_DaoMetaDataImpl.class.php(182):
S2Dao_DaoMetaDataImpl->setupUpdateMethodByAuto(Object(ReflectionMethod))
#6
/Users/webadmin/lib/S2Dao/build/s2dao.php5/S2Dao/S2Dao_DaoMetaDataImpl.class.php(105):
S2Dao_DaoMetaDataImpl->setupMethodByAuto(Object(ReflectionMethod))
#7
/Users/webadmin/lib/S2Dao/build/s2dao.php5/S2Dao/S2Dao_DaoMetaDataImpl.class.php(87):
S2Dao_DaoMetaDataImpl->setupMethod(Object(ReflectionMethod))
#8
/Users/webadmin/lib/S2Dao/build/s2dao.php5/S2Dao/S2Dao_DaoMetaDataImpl.class.php(77):
S2Dao_DaoMetaDataImpl->setupSqlCommand()
#9 /Users/webadmin/lib/S2Dao/build/s2dao.php5/s2dao.core.classes.php(1461):
S2Dao_DaoMetaDataImpl->__construct(Object(ReflectionClass),
Object(S2Container_PDODataSource), Object(S2Dao_BasicStatementFactory),
Object(S2Dao_BasicResultSetFactory),
Object(S2Dao_FieldAnnotationReaderFactory))
#10 /Users/webadmin/lib/S2Dao/build/s2dao.php5/s2dao.core.classes.php(1505):
S2Dao_DaoMetaDataFactoryImpl->getDaoMetaData(Object(ReflectionClass))
#11
/Users/webadmin/lib/S2Container/build/s2container.php5/s2container.core.classes.php(3056):
S2DaoInterceptor->invoke(Object(S2Container_S2MethodInvocationImpl))
#12
/Users/webadmin/lib/S2Container/build/s2container.php5/S2Container/S2Container_AopProxyGenerator.class.php(83)
: eval()'d code(24): S2Container_S2MethodInvocationImpl->proceed()
#13
/Users/webadmin/lib/S2Container/build/s2container.php5/S2Container/S2Container_AopProxyGenerator.class.php(83)
: eval()'d code(45): UserDaoEnhancedByS2AOP->__call('findAllArray', Array)
#14
/Users/webadmin/public_html/s2prado/protected/logic/UserLogicImpl.class.php(18):
UserDaoEnhancedByS2AOP->findAllArray()
#15
/Users/webadmin/public_html/s2prado/protected/pages/UserGrid.class.php(14):
UserLogicImpl->findAllArray()
#16 /Users/webadmin/lib/s2prado/prado/framework/TComponent.php(102):
UserGrid->getData()
#17 /Users/webadmin/lib/s2prado/prado/framework/Web/UI/TControl.php(204):
TComponent->__get('Data')
#18
/Users/webadmin/public_html/s2prado/protected/pages/UserGrid.class.php(32):
TControl->__get('Data')
#19 /Users/webadmin/lib/s2prado/prado/framework/Web/UI/TControl.php(1286):
UserGrid->onLoad(NULL)
#20 /Users/webadmin/lib/s2prado/prado/framework/Web/UI/TPage.php(210):
TControl->loadRecursive()
#21 /Users/webadmin/lib/s2prado/prado/framework/Web/UI/TPage.php(193):
TPage->processNormalRequest(Object(THtmlWriter))
#22 /Users/webadmin/lib/s2prado/Teeda/Web/Services/SPageService.php(108):
TPage->run(Object(THtmlWriter))
#23 /Users/webadmin/lib/s2prado/Teeda/Web/Services/SPageService.php(96):
SPageService->runPage(Object(UserGrid), Array)
#24 /Users/webadmin/lib/s2prado/prado/framework/TApplication.php(1066):
SPageService->run()
#25 /Users/webadmin/lib/s2prado/prado/framework/TApplication.php(376):
TApplication->runService()
#26 /Users/webadmin/public_html/s2prado/index.php(29): TApplication->run()
#27 {main}
2.対象のテーブル
CREATE TABLE `users` (
`id` int(10) unsigned NOT NULL auto_increment,
`name` varchar(50) default NULL,
`email` varchar(255) character set utf8 collate utf8_bin NOT NULL default
'',
`pwd` varchar(255) default NULL,
`profile` text,
`created` datetime default NULL,
`modified` datetime default NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
3.対象のエンティティクラス
<?php
class UsersEntity {
const TABLE = "users";
public function __construct(){}
protected $id;
const id_COLUMN = "id";
public function setId($val){$this->id = $val;}
public function getId(){return $this->id;}
protected $name;
const name_COLUMN = "name";
public function setName($val){$this->name = $val;}
public function getName(){return $this->name;}
protected $email;
const email_COLUMN = "email";
public function setEmail($val){$this->email = $val;}
public function getEmail(){return $this->email;}
protected $pwd;
const pwd_COLUMN = "pwd";
public function setPwd($val){$this->pwd = $val;}
public function getPwd(){return $this->pwd;}
protected $profile;
const profile_COLUMN = "profile";
public function setProfile($val){$this->profile = $val;}
public function getProfile(){return $this->profile;}
protected $created;
const created_COLUMN = "created";
public function setCreated($val){$this->created = $val;}
public function getCreated(){return $this->created;}
protected $modified;
const modified_COLUMN = "modified";
public function setModified($val){$this->modified = $val;}
public function getModified(){return $this->modified;}
public function __toString() {
$buf = array();
$buf[] = 'id => ' . $this->getId();
$buf[] = 'name => ' . $this->getName();
$buf[] = 'email => ' . $this->getEmail();
$buf[] = 'pwd => ' . $this->getPwd();
$buf[] = 'profile => ' . $this->getProfile();
$buf[] = 'created => ' . $this->getCreated();
$buf[] = 'modified => ' . $this->getModified();
return '{' . implode(', ',$buf) . '}';
}
/*
private $prop;
const prop_RELNO = 0;
const prop_RELKEYS = 'this_fk:other_pk';
public function setProp(OtherEntity $entity){ $this->prop = $entity; }
public function getProp(){ return $this->prop; }
*/
}
4.対象のDao
<?php
interface UserDao {
const BEAN = "UsersEntity";
public function findAllList();
public function findAllArray();
public function update(UsersEntity $entity);
public function insert(UsersEntity $entity);
public function delete(UsersEntity $entity);
}
?>
以上です。
--
------------------------------------------------------------------
植山 能成@福岡
mailto:[E-MAIL ADDRESS DELETED]
------------------------------------------------------------------
-------------- next part --------------
HTMLの添付ファイルを保管しました...
URL: http://ml.seasar.org/archives/s2container-php5/attachments/20070808/eb84b4b3/attachment-0001.html
S2Container-PHP5 メーリングリストの案内