netbeans を介して derby にアクセスし、結果をすべてログに記録すると、適切なデータが得られますが、PHP-Java Bridge を介してまったく同じことを行うと、データが得られません。パッケージ:
com.m1sk.HelloBridge
public static String backTest() throws Exception
{
BackendLink back = new BackendLink();
return back.GetTourists();
}
メインを介して呼び出されると、次のようなものが得られます。
[{<Json Representation of the only object in the database>}]
これでいいのですが、この関数をPHP-Java Bridgeで呼び出すと
<?
$test = new Java("com.m1sk.HelloBridge");
echo "!!<br>";
echo $test->backTest();
?>
私は得る
!!
[]
基本的には関数を呼び出しますが、実際のデータベースにアクセスすると、何らかの理由で同じ結果が得られません!
編集
*Backend_DAO_DB_impl:*
EntityManager em;
public Backend_DAO_DB_impl()
{
String PersistenceName = "XYZ;
EntityManagerFactory emf = Persistence.createEntityManagerFactory(PersistenceName);
em =emf.createEntityManager();
}
public ArrayList<Tourist> GetTourists()
{
Query q = em.createQuery("from Tourist");
return (ArrayList<Tourist>) q.getResultList();
}
バックエンドリンク
public String GetTourists() throws Exception
{
ArrayList<Tourist> tourists = back.GetTourists();
JSONArray arr = new JSONArray();
for(Tourist t : tourists)
{
arr.add(JSONConverter.touristToJSON(t));
}
return arr.toJSONString();
}
back は Backend_DAO_DB_impl のオブジェクトです。BackendLink は、少なくとも Eclipse で実行している場合に機能します。JSONConverter に問題はありません。確認しました。したがって、コードの奥深くにある必要があります。つまり、ダービーまたは休止状態にある可能性があります。
私の現在の推測では、netbeans は、私が Java ブリッジで行っていないことを自動的に行うということです。
編集
ここに要求されたログは次のとおりです。カタリナ
Jul 25, 2012 9:16:06 AM org.hibernate.cfg.AnnotationBinder bindClass
INFO: Binding entity from annotated class: java5772_5140_9448_modelDB.TouristSite
Jul 25, 2012 9:16:06 AM org.hibernate.cfg.annotations.EntityBinder bindTable
INFO: Bind entity java5772_5140_9448_modelDB.TouristSite on table TouristSite
Jul 25, 2012 9:16:06 AM org.hibernate.cfg.AnnotationBinder bindClass
INFO: Binding entity from annotated class: java5772_5140_9448_modelDB.InsideSites
Jul 25, 2012 9:16:06 AM org.hibernate.cfg.AnnotationBinder bindClass
INFO: Binding entity from annotated class: java5772_5140_9448_modelDB.OutsideSites
Jul 25, 2012 9:16:06 AM org.hibernate.cfg.AnnotationBinder bindClass
INFO: Binding entity from annotated class: java5772_5140_9448_modelDB.TourReservation
Jul 25, 2012 9:16:06 AM org.hibernate.cfg.annotations.EntityBinder bindTable
INFO: Bind entity java5772_5140_9448_modelDB.TourReservation on table TourReservation
Jul 25, 2012 9:16:06 AM org.hibernate.cfg.AnnotationBinder bindClass
INFO: Binding entity from annotated class: java5772_5140_9448_modelDB.Tourist
Jul 25, 2012 9:16:06 AM org.hibernate.cfg.annotations.EntityBinder bindTable
INFO: Bind entity java5772_5140_9448_modelDB.Tourist on table Tourist
Jul 25, 2012 9:16:06 AM org.hibernate.cfg.AnnotationConfiguration secondPassCompile
**INFO: Hibernate Validator not found: ignoring**
Jul 25, 2012 9:16:06 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Using Hibernate built-in connection pool (not for production use!)
Jul 25, 2012 9:16:06 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: Hibernate connection pool size: 20
Jul 25, 2012 9:16:06 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: autocommit mode: true
Jul 25, 2012 9:16:06 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: using driver: org.apache.derby.jdbc.ClientDriver at URL: jdbc:derby://localhost:1527/sample
Jul 25, 2012 9:16:06 AM org.hibernate.connection.DriverManagerConnectionProvider configure
INFO: connection properties: {user=app, password=****, autocommit=true, release_mode=auto}
Jul 25, 2012 9:16:06 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: RDBMS: Apache Derby, version: 10.8.1.2 - (1095077)
Jul 25, 2012 9:16:06 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC driver: Apache Derby Network Client JDBC Driver, version: 10.2.2.1 - (538595)
Jul 25, 2012 9:16:06 AM org.hibernate.dialect.Dialect <init>
INFO: Using dialect: org.hibernate.dialect.DerbyDialect
Jul 25, 2012 9:16:06 AM org.hibernate.transaction.TransactionFactoryFactory buildTransactionFactory
INFO: Transaction strategy: org.hibernate.transaction.JDBCTransactionFactory
Jul 25, 2012 9:16:06 AM org.hibernate.transaction.TransactionManagerLookupFactory getTransactionManagerLookup
INFO: No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
Jul 25, 2012 9:16:06 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic flush during beforeCompletion(): disabled
Jul 25, 2012 9:16:06 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Automatic session close at end of transaction: disabled
Jul 25, 2012 9:16:06 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Scrollable result sets: enabled
Jul 25, 2012 9:16:06 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JDBC3 getGeneratedKeys(): disabled
Jul 25, 2012 9:16:06 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Connection release mode: auto
Jul 25, 2012 9:16:06 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default batch fetch size: 1
Jul 25, 2012 9:16:06 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Generate SQL with comments: disabled
Jul 25, 2012 9:16:06 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL updates by primary key: disabled
Jul 25, 2012 9:16:06 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Order SQL inserts for batching: disabled
Jul 25, 2012 9:16:06 AM org.hibernate.cfg.SettingsFactory createQueryTranslatorFactory
INFO: Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
Jul 25, 2012 9:16:06 AM org.hibernate.hql.ast.ASTQueryTranslatorFactory <init>
INFO: Using ASTQueryTranslatorFactory
Jul 25, 2012 9:16:06 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query language substitutions: {}
Jul 25, 2012 9:16:06 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: JPA-QL strict compliance: enabled
Jul 25, 2012 9:16:06 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Second-level cache: enabled
Jul 25, 2012 9:16:06 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Query cache: disabled
Jul 25, 2012 9:16:06 AM org.hibernate.cfg.SettingsFactory createCacheProvider
INFO: Cache provider: org.hibernate.cache.NoCacheProvider
Jul 25, 2012 9:16:06 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Optimize cache for minimal puts: disabled
Jul 25, 2012 9:16:06 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Structured second-level cache entries: disabled
Jul 25, 2012 9:16:06 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Statistics: disabled
Jul 25, 2012 9:16:06 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Deleted entity synthetic identifier rollback: disabled
Jul 25, 2012 9:16:06 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Default entity-mode: pojo
Jul 25, 2012 9:16:06 AM org.hibernate.cfg.SettingsFactory buildSettings
INFO: Named query checking : enabled
Jul 25, 2012 9:16:06 AM org.hibernate.impl.SessionFactoryImpl <init>
INFO: building session factory
Jul 25, 2012 9:16:06 AM org.hibernate.impl.SessionFactoryObjectFactory addInstance
INFO: Not binding factory to JNDI, no JNDI name configured
Jul 25, 2012 9:16:06 AM org.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: Running hbm2ddl schema export
Jul 25, 2012 9:16:06 AM org.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: exporting generated schema to database
Jul 25, 2012 9:16:08 AM org.hibernate.tool.hbm2ddl.SchemaExport execute
INFO: schema export complete
他はOKのようです。その行についてはよくわかりません。