我有一个使用[
{
"$ref": "ObjectName",
"$id": {
"$oid": "4f835168e4b041cb4cf48119"
}
},
{
"$ref": "ObjectName",
"$id": {
"$oid": "4f834cade4b041cb4cf48108"
}
},
.... more element in the array ...
]
来处理数据库连接的应用程序。例如:
sessionFactory
但如果我运行此查询
public List<APN> getList() throws org.hibernate.HibernateException {
List<APN> result = (List<APN>) sessionFactory.getCurrentSession()
.createQuery("from APN").list();
return result;
}
不会给出任何行。这是否意味着,hibernate每次都会重新创建会话?这可以吗?这是否意味着hibernate为每个查询创建新的jdbc连接?我知道这是一个有点沉重的程序。
hibernate.cfg.xml中:
select * from v$session where username='MY_USER'
root-context:
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">300</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
<mapping class="ru.tenet.pcrf.domain.RedirectionServer" />
<mapping class="ru.tenet.pcrf.domain.DeviceType" />
<mapping class="ru.tenet.pcrf.domain.FlowTemplate" />
<mapping class="ru.tenet.pcrf.domain.QoS" />
<mapping class="ru.tenet.pcrf.domain.MonitoringKey" />
<mapping class="ru.tenet.pcrf.domain.Rule" />
<mapping class="ru.tenet.pcrf.domain.RuleFlows" />
<mapping class="ru.tenet.pcrf.domain.Policy" />
<mapping class="ru.tenet.pcrf.domain.PolicyContent" />
<mapping class="ru.tenet.pcrf.domain.APN" />
<mapping class="ru.tenet.pcrf.domain.Location" />
<mapping class="ru.tenet.pcrf.domain.QuotaTemplate" />
<mapping class="ru.tenet.pcrf.domain.SGSNNode" />
<mapping class="ru.tenet.pcrf.domain.RuleSCE" />
<mapping class="ru.tenet.pcrf.domain.Protocol" />
<mapping class="ru.tenet.pcrf.domain.Peer" />
<mapping class="ru.tenet.pcrf.domain.User" />
<mapping class="ru.tenet.pcrf.domain.Role" />
<mapping class="ru.tenet.pcrf.domain.SessionList" />
<mapping class="ru.tenet.pcrf.domain.SessionRule" />
<mapping class="ru.tenet.pcrf.domain.SessionLocation" />
<mapping class="ru.tenet.pcrf.domain.SubscriptionData" />
<mapping class="ru.tenet.pcrf.domain.Subscriber" />
<mapping class="ru.tenet.pcrf.domain.SubscriberPolicy" />
<mapping class="ru.tenet.pcrf.domain.SubscriberQuota" />
<mapping class="ru.tenet.pcrf.domain.Device" />
<mapping class="ru.tenet.pcrf.domain.RequestCounter" />
<mapping class="ru.tenet.pcrf.domain.SessionCounter" />
</session-factory>
</hibernate-configuration>