- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我有一个具有属性 @Formula 的实体,如下所示:
@Entity
@Table(name = "areasAuxiliar")
public final class AreaAuxiliar implements Serializable {
@Id
@Column(name = "idArea")
private Integer idArea;
@Formula("RUTAAREA(idArea)")
private String ruta;
当我将我的 hibernate 配置为指向 Oracle 数据库时,我没有遇到任何问题,但是,当我切换到 SQLServer 时, hibernate 不包括 shema 并且查询失败,
为 hibernate 生成的查询如下所示:
select
areaauxili4_.idArea as idArea1_6_4_,
rutaArea(areaauxili4_.idArea) as formula2_4_
from
SIGAP.areasAuxiliar areaauxili4_
正在读取参数 hibernate.default_schema=SIGAP 并将其包含在表中,但不包含在函数中,
是否有一个选项/注释可以在该函数中强制使用 shema?
我试过 hibernate 5.1 和 5.2,结果相同 :(
最佳答案
您可以使用 mysql-orm.xml
文件来覆盖您的公式,然后将您的构建配置为在数据库为 mysql 时考虑该文件。
在这里重写公式:
<entity-mappings
xmlns="http://xmlns.jcp.org/xml/ns/persistence/orm"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence/orm orm_2_1.xsd"
version="2.1">
<package>com.acme.persistence</package>
<entity class="AreaAuxiliar" access="FIELD">
<attributes>
<property name="ruta" formula="schemaName.RUTAAREA(idarea)"/>
</attributes>
</entity>
</entity-mappings>
然后在特定的persistence.xml
中添加引用。然后,您可以在您的构建中或在运行时用这个文件覆盖您的默认 persistence.xml(参见下面的链接)。
<persistence
xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
version="2.1">
<persistence-unit name="persistenceUnit">
<provider>
org.hibernate.jpa.HibernatePersistenceProvider
</provider>
<mapping-file>
mappings/identifier/global/mysql-orm.xml
</mapping-file>
<class>
com.acme.persistence.AreaAuxiliar
</class>
</persistence-unit>
注:灵感来自 How to change Hibernate GenerationType identifier depending on the underlying database
关于java - Hibernate @Formula 不包含 Schema,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51088034/
我正在尝试使用神经网络进行预测。 创建一些X: x f y ~ x1 + x2 ## fit model using `f` model model Call: neuralnet(formula
我要字段idEmpresa使用 idDepartamento 成为@Formula 字段(这是另一个@Formula 字段)在 WHERE陈述。 @Entity public class CfgUsu
我正在使用Google Apps脚本从概念数据库中查询数据,并在我的Google日历中创建日历事件。。我遇到了一些奇怪的行为,我搞不懂。。我的概念数据库为每个事件都有一个条目。每个事件都有开始和结束日
例如:将公式左侧的7个单元格相加。。值得注意的是,当在其左侧或范围内的某个位置插入新列时,该公式应该起作用。不扩展范围,不跳过新插入的列。
例如:将公式左侧的7个单元格相加。。值得注意的是,当在其左侧或范围内的某个位置插入新列时,该公式应该起作用。不扩展范围,不跳过新插入的列。
例如:将公式左侧的7个单元格相加。。值得注意的是,当在其左侧或范围内的某个位置插入新列时,该公式应该起作用。不扩展范围,不跳过新插入的列。
示例:对公式左侧的7个单元格求和。。值得注意的是,当在其左侧或范围内的某个位置插入新列时,该公式应该起作用。不扩展范围,不跳过新插入的列。
我需要帮助才能在 MS Excel 工作表中执行以下功能。工作表示例如下 A B C D E 1
好的, 我有一个射弹,其位置定义如下: a.x = initialX + initialDX * time; a.y = initialY + initialDY * time + 0.5 * gra
我正在尝试根据另一个点的经度计算一个点的经度。它们具有相同的纬度,并且它们之间的距离是已知的。我尝试使用余弦的特殊定律公式。 # 'lat' short for 'latitude', 'lng' s
我使用haversine公式来计算点之间的距离。这个公式的结果是米还是公里? http://en.wikipedia.org/wiki/Haversine_formula 任何人都可以帮助我吗?
取消使用鱼眼镜头或广角镜头制作的照片的最简单方法是什么?我正在寻找一个参数很少的像素投影公式。相机和镜头参数将不可知,因此用户必须直观地更改参数。谢谢 最佳答案 有好纸here这为镜头畸变提供了一些看
当使用来自 Formula package 的 Formula() 或 as.Formula() 时,我收到一条警告消息。它似乎不会影响功能,但我无法理解它的来源。 我正在使用 Formula 包更新
我正在使用这个公式来显示本月剩余的天数。是否可以在工作日内执行此操作? =EOMONTH(TODAY(),0)-TODAY() 最佳答案 分析工具包还提供函数 NETWORKDAYS 来查找两个日期之
我正在向字段添加公式: @Formula(value = "(select count(*) from approvalGroup as a where a.isAccounting=true)")
我想根据标准在下面的 C 列中使用 IF 公式发表评论: A B C 10 56% Leader 20 10% Laggard 55 45% Mover 90 90% Cashco
有没有更优雅(更简单)的方式将变量放入.formula?我不想使用 .formulaR1C1 我有这个代码: Range("C8").Select Selection.End(xlDown).Sele
我在 excel 中解析字符串,我需要通过最后一个数字返回所有内容。例如: Input: A00XX Output: A00 在我的情况下,我知道最后一个数字将在索引 3 和 5 之间,所以我用暴力强
我有一个包含两张纸的 LibreOffice Calc 文件。表 2 只有一列 A 有很多数字。在工作表 1 中,每行的 A 列也包含一个数字。我想从工作表 1 中删除所有在 A 列中具有值的行,这些
Excel的范围下拉(或拖拽)操作的公式是什么? 输入2,5,7,9然后向下拖动,显示11.5 13.8 16.1 18.4 ....步骤2.3 输入5,10,20然后向下拖动,显示26.66667
我是一名优秀的程序员,十分优秀!