orm

hibernate: create table with names in lowercase

冷暖自知 提交于 2020-01-24 05:27:03
问题 Hibernate: I want to have hibernate automatically generate my tables with names in lowercase. For example, if my class is called com.myapp.domain.Customer, hibernate will generate a table named Customer. I want it to be called customer. I know I can use the @Table annotation to specify the table name per class. But I want it to happen "automagically". 回答1: Isn'it it the job for NamingStrategy? You would get the name of the entity managed (i.e. Customer) and should decide the table name used (

Doctrine not working unless I explicitly call AnnotationDriver::getAllClassNames

别说谁变了你拦得住时间么 提交于 2020-01-24 03:53:25
问题 I'm attempting to use Doctrine ORM for the first time, and I'm following the configuration found here. Following these steps directly results in the following error: Warning: class_parents() [function.class-parents]: Class MyProject\Model\User does not exist and could not be loaded in /opt/local/lib/php/Doctrine/ORM/Mapping/ClassMetadataFactory.php on line 222 Warning: array_reverse() expects parameter 1 to be array, boolean given in /opt/local/lib/php/Doctrine/ORM/Mapping

Is there generic Specification for JPASpecificationExecutor to use in Web

淺唱寂寞╮ 提交于 2020-01-23 18:24:21
问题 Spring Data has a native web support for Pageable send over the web, as parameters in HTML Query, through PageableHandlerMethodArgumentResolver. I have not found JPA Specification executor for that, which from my point of view would be very useful. Is there one? 回答1: The reason that there's no generic one available for you is that the predicates you build in it is completely depending on your domain model. A good example for how to use Specification s with Spring MVC can be found in the

Is there generic Specification for JPASpecificationExecutor to use in Web

僤鯓⒐⒋嵵緔 提交于 2020-01-23 18:24:06
问题 Spring Data has a native web support for Pageable send over the web, as parameters in HTML Query, through PageableHandlerMethodArgumentResolver. I have not found JPA Specification executor for that, which from my point of view would be very useful. Is there one? 回答1: The reason that there's no generic one available for you is that the predicates you build in it is completely depending on your domain model. A good example for how to use Specification s with Spring MVC can be found in the

【Hibernate】Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set

五迷三道 提交于 2020-01-23 13:26:41
今天用hibernate框架写crm项目时遇到报错: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set 说是hibernate的dialect没有设置,但是在hibernate.cfg,xml中我已经配置了。主要内容如下: hibernate.cfg.xml: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <!-- 必选属性 (5个)--> <!-- 数据库驱动 --> <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property> <!-- 数据库url --> <property name="hibernate.connection.url"

Spring Boot (三): ORM 框架 JPA 与连接池 Hikari

妖精的绣舞 提交于 2020-01-23 13:17:03
前面两篇文章我们介绍了如何快速创建一个 Spring Boot 工程 《Spring Boot(一):快速开始》 和在 Spring Boot 中如何使用模版引擎 Thymeleaf 渲染一个Web页面 《Spring Boot (二):模版引擎 Thymeleaf 渲染 Web 页面》 ,本篇文章我们继续介绍在 Spring Boot 中如何使用数据库。 1. 概述 数据库方面我们选用 Mysql , Spring Boot 提供了直接使用 JDBC 的方式连接数据库,毕竟使用 JDBC 并不是很方便,需要我们自己写更多的代码才能使用,一般而言在 Spring Boot 中我们常用的 ORM 框架有 JPA 和 Mybaties ,本篇文章我们要介绍的就是 JPA 的使用姿势。 说道使用 ORM 框架,就不得不顺便聊一下连接池,市面上很多成熟的数据库连接池,如 C3P0 、 Tomcat 连接池、 BoneCP 等等很多产品,但是我们为什么要介绍 Hikari ?这个要从 BoneCP 说起。 因为,传说中 BoneCP 在快速这个特点上做到了极致,官方数据是C3P0等的25倍左右。不相信?其实我也不怎么信。可是,有图有真相啊,传说图片来源于官网,然而笔者在官网并没有找到,大家看一下: 看起来是不是完全吊打,但是当 HikariCP 横空出世以后,这个局面就被完全改写了,

Example websites using db4o

亡梦爱人 提交于 2020-01-23 08:26:07
问题 I'm very impressed with my initial tests with db4o. However, i'm wondering just how many enterprise class websites are out there powered by db4o, i couldn't see any on the main website? I can't see any reason why db4o should not be used. There appears to be decent enough support for transactions and ways to handle concurrency for example. Anyone got a list of websites i could look at? 回答1: See: http://developer.db4o.com/Projects/html/projectspaces/gaabormarkt.html 回答2: A particular search

How can I optimize this query produced by SQLAlchemy?

时光总嘲笑我的痴心妄想 提交于 2020-01-23 05:47:11
问题 I have a query generated by SQLAlchemy ORM. It is supposed to retrieve stream_items for a specific course, along with all of their parts - resources, content text blocks, etc., and the users who posted them. However, this query appears to be extremely slow, taking minutes on our production database with 20,000 or so users in the database, 25 or so stream_items for the course, and a couple content text blocks per stream_item. Note that there are very few of any other records besides users in

How to debug “Found two representations of same collection”?

人盡茶涼 提交于 2020-01-23 04:30:07
问题 I have found several questions about this, but none with a complete explaintation of the problem, and how to debug it - the answers are all anecdotal. The problem is that in a Play 1.2.4 JPA test, I'm getting this exception when I save() a model: org.hibernate.HibernateException: Found two representations of same collection: models.Position.projects I would like to know: Is there a documentation of this problem in general, unrelated to Play? The issue is in hibernate, yet a lot of the Google

connect SQLAlchemy ORM with the objects from sql core expression?

社会主义新天地 提交于 2020-01-23 01:48:29
问题 I have to use SQLalchemy Core expression to fetch objects because ORM can't do "update and returning". (the update in ORM doesn't has returning ) from sqlalchemy import update class User(ORMBase): ... # pure sql expression, the object returned is not ORM object. # the object is a RowProxy. object = update(User) \ .values({'name': 'Wayne'}) \ .where(User.id == subquery.as_scalar()) \ .returning() \ .fetchone() When db_session.add(object) it report UnmappedInstanceError: Class 'sqlalchemy