> So.. the question becomes: how can I integrate Cayenne in an OSGi Environmnet?


I wish I'd get myself into an OSGi project to have some motivation to 
familiarize myself with OSGi-related issues :) For now, there are various 
degrees of interest and an intent to help from different folks, but nothing 
specific as of yet: 

http://markmail.org/message/n7licqa27qdecfzy
http://markmail.org/message/admkhniktnvnfid5

Andrus



On Sep 7, 2012, at 10:45 AM, Francesco Romano wrote:
> Ok.. I found the problem.. It is not related to Cayenne, but to our 
> environment.
> 
> So.. the question becomes: how can I integrate Cayenne in an OSGi Environmnet?
> 
> Francesco
> 
> On Sep 6, 2012, at 5:00 PM, Francesco Romano wrote:
> 
>> Hi everybody.
>> 
>> I have a problem with cayenne.
>> I migrated a table from having a PK autogenerated by the db on a field ID, 
>> to a table without autogenerated pks (now my PK is a multi-column table).
>> 
>> The problem is that I have this exception during execution:
>> 
>> [06Sep 16:55:16,714] (CommitObjects@295) WARN  KPIServiceImpl - Error 
>> committing kpiManager.TotalLatencyStat
>> org.apache.cayenne.CayenneRuntimeException: [v.3.0 Apr 26 2010 09:59:17] 
>> Commit Exception
>>      at 
>> org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:1134)
>>      at 
>> org.apache.cayenne.access.DataContext.commitChanges(DataContext.java:1045)
>>      at kpi.impl.KPIServiceImpl.CommitObjects(KPIServiceImpl.java:285)
>>      at kpi.impl.KPIServiceImpl.saveObj(KPIServiceImpl.java:2518)
>>      at impl.KPIServiceImpl.addTotalLatencyStat(KPIServiceImpl.java:989)
>>      at timertask.JMSMsgStatKPITimerTask.run(JMSMsgStatKPITimerTask.java:47)
>>      at java.util.TimerThread.mainLoop(Timer.java:512)
>>      at java.util.TimerThread.run(Timer.java:462)
>> Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 
>> 'kpidb.auto_pk_support' doesn't exist
>>      at sun.reflect.GeneratedConstructorAccessor143.newInstance(Unknown 
>> Source)
>>      at 
>> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>>      at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
>>      at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
>>      at com.mysql.jdbc.Util.getInstance(Util.java:381)
>>      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1030)
>>      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
>>      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3515)
>>      at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3447)
>>      at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1951)
>>      at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2101)
>>      at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2548)
>>      at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2477)
>>      at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:741)
>>      at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:587)
>>      at 
>> org.apache.cayenne.dba.mysql.MySQLPkGenerator.getLongPrimaryKey(MySQLPkGenerator.java:305)
>>      at 
>> org.apache.cayenne.dba.mysql.MySQLPkGenerator.longPkFromDatabase(MySQLPkGenerator.java:81)
>>      at 
>> org.apache.cayenne.dba.JdbcPkGenerator.generatePk(JdbcPkGenerator.java:270)
>>      at 
>> org.apache.cayenne.access.DataDomainInsertBucket.createPermIds(DataDomainInsertBucket.java:165)
>>      at 
>> org.apache.cayenne.access.DataDomainInsertBucket.appendQueriesInternal(DataDomainInsertBucket.java:76)
>>      at 
>> org.apache.cayenne.access.DataDomainSyncBucket.appendQueries(DataDomainSyncBucket.java:79)
>>      at 
>> org.apache.cayenne.access.DataDomainFlushAction.preprocess(DataDomainFlushAction.java:182)
>>      at 
>> org.apache.cayenne.access.DataDomainFlushAction.flush(DataDomainFlushAction.java:134)
>>      at org.apache.cayenne.access.DataDomain.onSyncFlush(DataDomain.java:824)
>>      at org.apache.cayenne.access.DataDomain$2.transform(DataDomain.java:791)
>>      at 
>> org.apache.cayenne.access.DataDomain.runInTransaction(DataDomain.java:850)
>>      at org.apache.cayenne.access.DataDomain.onSync(DataDomain.java:788)
>>      at 
>> org.apache.cayenne.access.DataContext.flushToParent(DataContext.java:1106)
>>      ... 7 more
>> 
>> But.. date is written into db!!
>> This is the db-entity and obj-entity for the table 
>> 
>> <db-entity name="TotalLatencyStat">
>>              <db-attribute name="DataType" type="INTEGER" 
>> isPrimaryKey="true" isMandatory="true"/>
>>              <db-attribute name="LatencyMax" type="INTEGER" 
>> isMandatory="true"/>
>>              <db-attribute name="LatencyMin" type="INTEGER" 
>> isMandatory="true"/>
>>              <db-attribute name="LatencySum" type="INTEGER" 
>> isMandatory="true"/>
>>              <db-attribute name="MacAddress" type="VARBINARY" 
>> isPrimaryKey="true" isMandatory="true" length="128"/>
>>              <db-attribute name="MsgNumber" type="INTEGER" 
>> isMandatory="true"/>
>>              <db-attribute name="NetworkID" type="INTEGER" 
>> isPrimaryKey="true" isMandatory="true"/>
>>              <db-attribute name="ServiceType" type="INTEGER" 
>> isPrimaryKey="true" isMandatory="true"/>
>>              <db-attribute name="Timestamp" type="BIGINT" 
>> isPrimaryKey="true" isMandatory="true"/>
>>      </db-entity>
>> 
>> <obj-entity name="TotalLatencyStat" 
>> className="com.abodata.plat1.kpiManager.TotalLatencyStat" 
>> lock-type="optimistic" dbEntityName="TotalLatencyStat">
>>              <obj-attribute name="dataType" type="int" 
>> db-attribute-path="DataType"/>
>>              <obj-attribute name="latencyMax" type="int" 
>> db-attribute-path="LatencyMax"/>
>>              <obj-attribute name="latencyMin" type="int" 
>> db-attribute-path="LatencyMin"/>
>>              <obj-attribute name="latencySum" type="int" 
>> db-attribute-path="LatencySum"/>
>>              <obj-attribute name="macAddress" type="byte[]" 
>> db-attribute-path="MacAddress"/>
>>              <obj-attribute name="msgNumber" type="int" 
>> db-attribute-path="MsgNumber"/>
>>              <obj-attribute name="networkID" type="int" 
>> db-attribute-path="NetworkID"/>
>>              <obj-attribute name="serviceType" type="int" 
>> db-attribute-path="ServiceType"/>
>>              <obj-attribute name="timestamp" type="long" 
>> db-attribute-path="Timestamp"/>
>>      </obj-entity>
>> 
>> I don't understand the exception above!
>> I also tried to put a breakpoint in the source code of cayenne, in 
>> particular in BatchAction.runAsIndividualQueries.
>> generatesKeys is false. I also put a breakpoint inside the then-block of
>> if (generatesKeys) {
>>     processGeneratedKeys(statement, delegate);
>> }
>> and it is never fired!
>> 
>> I add that I use Cayenne 3.0
>> 
>> Thanks 
>> 
>> Francesco Romano
>> 
>> 
> 
> 

Reply via email to