- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用 jOOQ 3.8.4 和 Postgres 9.5。我有一个复杂的架构。实际上,当我做一个简单的选择时,比如:
create.selectFrom(ARTICLE_VIEW)
.orderBy(ARTICLE_VIEW.AV_CREATION_DATE
.desc()).limit(4).fetch();
我得到:
java.lang.StackOverflowError
org.jooq.Converters$1.<init>(Converters.java:67)
org.jooq.Converters.identity(Converters.java:67)
org.jooq.impl.DefaultBinding.pgFromString(DefaultBinding.java:2041)
org.jooq.impl.DefaultBinding.pgFromString(DefaultBinding.java:2130)
org.jooq.impl.DefaultBinding.pgFromString(DefaultBinding.java:2041)
org.jooq.impl.DefaultBinding.pgFromString(DefaultBinding.java:2130)
org.jooq.impl.DefaultBinding.pgFromString(DefaultBinding.java:2041)
还有更多(有趣,这是我的第一个 StackOverflowException
)!
我激活了 DEBUG 日志记录模式,我复制了选择并在 PGAdmin 中执行它。有用。 jOOQ应该有问题,但我不知道如何提供有用的信息。发布我使用的模式会很疯狂,它需要几十个表。关于如何进行的任何提示?
更新
下面是记录类
/**
* This class is generated by jOOQ
*/
package com.model.jooq.shop.tables.records;
import com.google.gson.JsonElement;
import com.model.jooq.shop.enums.BrandCountry;
import com.model.jooq.shop.enums.Color;
import com.model.jooq.shop.enums.Discount;
import com.model.jooq.shop.enums.Season;
import com.model.jooq.shop.tables.ArticleView;
import com.model.jooq.shop.udt.records.ArticleSimpleTypeRecord;
import com.model.jooq.shop.udt.records.CategoryTypeRecord;
import com.model.jooq.shop.udt.records.LocalizedMoneyRecord;
import com.model.jooq.shop.udt.records.SameModelArticleTypeRecord;
import java.io.Serializable;
import java.sql.Timestamp;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import org.jooq.impl.TableRecordImpl;
/**
* This class is generated by jOOQ.
*/
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
@Entity
@Table(name = "article_view", schema = "shop")
public class ArticleViewRecord extends TableRecordImpl<ArticleViewRecord> implements Serializable, Cloneable {
private static final long serialVersionUID = -1404712730;
/**
* Setter for <code>shop.article_view.av_article_id</code>.
*/
public ArticleViewRecord setArticleId(Long value) {
set(0, value);
return this;
}
/**
* Getter for <code>shop.article_view.av_article_id</code>.
*/
@Column(name = "av_article_id", precision = 64)
public Long getArticleId() {
return (Long) get(0);
}
/**
* Setter for <code>shop.article_view.av_article_model_id</code>.
*/
public ArticleViewRecord setArticleModelId(Long value) {
set(1, value);
return this;
}
/**
* Getter for <code>shop.article_view.av_article_model_id</code>.
*/
@Column(name = "av_article_model_id", precision = 64)
public Long getArticleModelId() {
return (Long) get(1);
}
/**
* Setter for <code>shop.article_view.av_article_name</code>.
*/
public ArticleViewRecord setArticleName(String value) {
set(2, value);
return this;
}
/**
* Getter for <code>shop.article_view.av_article_name</code>.
*/
@Column(name = "av_article_name", length = 25)
@Size(max = 25)
public String getArticleName() {
return (String) get(2);
}
/**
* Setter for <code>shop.article_view.av_article_name_for_url</code>.
*/
public ArticleViewRecord setArticleNameForUrl(String value) {
set(3, value);
return this;
}
/**
* Getter for <code>shop.article_view.av_article_name_for_url</code>.
*/
@Column(name = "av_article_name_for_url", length = 25)
@Size(max = 25)
public String getArticleNameForUrl() {
return (String) get(3);
}
/**
* Setter for <code>shop.article_view.av_article_season</code>.
*/
public ArticleViewRecord setArticleSeason(Season value) {
set(4, value);
return this;
}
/**
* Getter for <code>shop.article_view.av_article_season</code>.
*/
@Column(name = "av_article_season")
public Season getArticleSeason() {
return (Season) get(4);
}
/**
* Setter for <code>shop.article_view.av_article_year</code>.
*/
public ArticleViewRecord setArticleYear(Short value) {
set(5, value);
return this;
}
/**
* Getter for <code>shop.article_view.av_article_year</code>.
*/
@Column(name = "av_article_year", precision = 16)
public Short getArticleYear() {
return (Short) get(5);
}
/**
* Setter for <code>shop.article_view.av_article_standard_size_designation</code>.
*/
public ArticleViewRecord setArticleStandardSizeDesignation(Boolean value) {
set(6, value);
return this;
}
/**
* Getter for <code>shop.article_view.av_article_standard_size_designation</code>.
*/
@Column(name = "av_article_standard_size_designation")
public Boolean getArticleStandardSizeDesignation() {
return (Boolean) get(6);
}
/**
* Setter for <code>shop.article_view.av_article_ean13</code>.
*/
public ArticleViewRecord setArticleEan13(String value) {
set(7, value);
return this;
}
/**
* Getter for <code>shop.article_view.av_article_ean13</code>.
*/
@Column(name = "av_article_ean13", length = 13)
@Size(max = 13)
public String getArticleEan13() {
return (String) get(7);
}
/**
* Setter for <code>shop.article_view.av_article_config_sku</code>.
*/
public ArticleViewRecord setArticleConfigSku(String value) {
set(8, value);
return this;
}
/**
* Getter for <code>shop.article_view.av_article_config_sku</code>.
*/
@Column(name = "av_article_config_sku", length = 12)
@Size(max = 12)
public String getArticleConfigSku() {
return (String) get(8);
}
/**
* Setter for <code>shop.article_view.av_article_features</code>.
*/
public ArticleViewRecord setArticleFeatures(JsonElement value) {
set(9, value);
return this;
}
/**
* Getter for <code>shop.article_view.av_article_features</code>.
*/
@Column(name = "av_article_features")
public JsonElement getArticleFeatures() {
return (JsonElement) get(9);
}
/**
* Setter for <code>shop.article_view.av_article_color</code>.
*/
public ArticleViewRecord setArticleColor(Color value) {
set(10, value);
return this;
}
/**
* Getter for <code>shop.article_view.av_article_color</code>.
*/
@Column(name = "av_article_color")
public Color getArticleColor() {
return (Color) get(10);
}
/**
* Setter for <code>shop.article_view.av_article_color2</code>.
*/
public ArticleViewRecord setArticleColor2(Color value) {
set(11, value);
return this;
}
/**
* Getter for <code>shop.article_view.av_article_color2</code>.
*/
@Column(name = "av_article_color2")
public Color getArticleColor2() {
return (Color) get(11);
}
/**
* Setter for <code>shop.article_view.av_article_color3</code>.
*/
public ArticleViewRecord setArticleColor3(Color value) {
set(12, value);
return this;
}
/**
* Getter for <code>shop.article_view.av_article_color3</code>.
*/
@Column(name = "av_article_color3")
public Color getArticleColor3() {
return (Color) get(12);
}
/**
* Setter for <code>shop.article_view.av_article_color_detail</code>.
*/
public ArticleViewRecord setArticleColorDetail(JsonElement value) {
set(13, value);
return this;
}
/**
* Getter for <code>shop.article_view.av_article_color_detail</code>.
*/
@Column(name = "av_article_color_detail")
public JsonElement getArticleColorDetail() {
return (JsonElement) get(13);
}
/**
* Setter for <code>shop.article_view.av_article_paid_price</code>.
*/
public ArticleViewRecord setArticlePaidPrice(LocalizedMoneyRecord[] value) {
set(14, value);
return this;
}
/**
* Getter for <code>shop.article_view.av_article_paid_price</code>.
*/
@Column(name = "av_article_paid_price")
public LocalizedMoneyRecord[] getArticlePaidPrice() {
return (LocalizedMoneyRecord[]) get(14);
}
/**
* Setter for <code>shop.article_view.av_article_price</code>.
*/
public ArticleViewRecord setArticlePrice(LocalizedMoneyRecord[] value) {
set(15, value);
return this;
}
/**
* Getter for <code>shop.article_view.av_article_price</code>.
*/
@Column(name = "av_article_price")
public LocalizedMoneyRecord[] getArticlePrice() {
return (LocalizedMoneyRecord[]) get(15);
}
/**
* Setter for <code>shop.article_view.av_article_image_filenames</code>.
*/
public ArticleViewRecord setArticleImageFilenames(String[] value) {
set(16, value);
return this;
}
/**
* Getter for <code>shop.article_view.av_article_image_filenames</code>.
*/
@Column(name = "av_article_image_filenames")
public String[] getArticleImageFilenames() {
return (String[]) get(16);
}
/**
* Setter for <code>shop.article_view.av_article_active_from</code>.
*/
public ArticleViewRecord setArticleActiveFrom(Timestamp value) {
set(17, value);
return this;
}
/**
* Getter for <code>shop.article_view.av_article_active_from</code>.
*/
@Column(name = "av_article_active_from")
public Timestamp getArticleActiveFrom() {
return (Timestamp) get(17);
}
/**
* Setter for <code>shop.article_view.av_article_discount</code>.
*/
public ArticleViewRecord setArticleDiscount(Discount value) {
set(18, value);
return this;
}
/**
* Getter for <code>shop.article_view.av_article_discount</code>.
*/
@Column(name = "av_article_discount")
public Discount getArticleDiscount() {
return (Discount) get(18);
}
/**
* Setter for <code>shop.article_view.av_brand_id</code>.
*/
public ArticleViewRecord setBrandId(Short value) {
set(19, value);
return this;
}
/**
* Getter for <code>shop.article_view.av_brand_id</code>.
*/
@Column(name = "av_brand_id", precision = 16)
public Short getBrandId() {
return (Short) get(19);
}
/**
* Setter for <code>shop.article_view.av_brand_name</code>.
*/
public ArticleViewRecord setBrandName(String value) {
set(20, value);
return this;
}
/**
* Getter for <code>shop.article_view.av_brand_name</code>.
*/
@Column(name = "av_brand_name", length = 25)
@Size(max = 25)
public String getBrandName() {
return (String) get(20);
}
/**
* Setter for <code>shop.article_view.av_brand_name_for_url</code>.
*/
public ArticleViewRecord setBrandNameForUrl(String value) {
set(21, value);
return this;
}
/**
* Getter for <code>shop.article_view.av_brand_name_for_url</code>.
*/
@Column(name = "av_brand_name_for_url", length = 25)
@Size(max = 25)
public String getBrandNameForUrl() {
return (String) get(21);
}
/**
* Setter for <code>shop.article_view.av_brand_country</code>.
*/
public ArticleViewRecord setBrandCountry(BrandCountry value) {
set(22, value);
return this;
}
/**
* Getter for <code>shop.article_view.av_brand_country</code>.
*/
@Column(name = "av_brand_country")
public BrandCountry getBrandCountry() {
return (BrandCountry) get(22);
}
/**
* Setter for <code>shop.article_view.av_brand_logo_url</code>.
*/
public ArticleViewRecord setBrandLogoUrl(String value) {
set(23, value);
return this;
}
/**
* Getter for <code>shop.article_view.av_brand_logo_url</code>.
*/
@Column(name = "av_brand_logo_url", length = 250)
@Size(max = 250)
public String getBrandLogoUrl() {
return (String) get(23);
}
/**
* Setter for <code>shop.article_view.av_brand_facts</code>.
*/
public ArticleViewRecord setBrandFacts(JsonElement value) {
set(24, value);
return this;
}
/**
* Getter for <code>shop.article_view.av_brand_facts</code>.
*/
@Column(name = "av_brand_facts")
public JsonElement getBrandFacts() {
return (JsonElement) get(24);
}
/**
* Setter for <code>shop.article_view.av_commodity_group_id</code>.
*/
public ArticleViewRecord setCommodityGroupId(Long value) {
set(25, value);
return this;
}
/**
* Getter for <code>shop.article_view.av_commodity_group_id</code>.
*/
@Column(name = "av_commodity_group_id", precision = 64)
public Long getCommodityGroupId() {
return (Long) get(25);
}
/**
* Setter for <code>shop.article_view.av_commodity_group_name</code>.
*/
public ArticleViewRecord setCommodityGroupName(String value) {
set(26, value);
return this;
}
/**
* Getter for <code>shop.article_view.av_commodity_group_name</code>.
*/
@Column(name = "av_commodity_group_name", length = 25)
@Size(max = 25)
public String getCommodityGroupName() {
return (String) get(26);
}
/**
* Setter for <code>shop.article_view.av_commodity_group_name_for_url</code>.
*/
public ArticleViewRecord setCommodityGroupNameForUrl(String value) {
set(27, value);
return this;
}
/**
* Getter for <code>shop.article_view.av_commodity_group_name_for_url</code>.
*/
@Column(name = "av_commodity_group_name_for_url", length = 25)
@Size(max = 25)
public String getCommodityGroupNameForUrl() {
return (String) get(27);
}
/**
* Setter for <code>shop.article_view.av_categories</code>.
*/
public ArticleViewRecord setCategories(CategoryTypeRecord[] value) {
set(28, value);
return this;
}
/**
* Getter for <code>shop.article_view.av_categories</code>.
*/
@Column(name = "av_categories")
public CategoryTypeRecord[] getCategories() {
return (CategoryTypeRecord[]) get(28);
}
/**
* Setter for <code>shop.article_view.av_sizes</code>.
*/
public ArticleViewRecord setSizes(ArticleSimpleTypeRecord[] value) {
set(29, value);
return this;
}
/**
* Getter for <code>shop.article_view.av_sizes</code>.
*/
@Column(name = "av_sizes")
public ArticleSimpleTypeRecord[] getSizes() {
return (ArticleSimpleTypeRecord[]) get(29);
}
/**
* Setter for <code>shop.article_view.av_all_model_colors</code>.
*/
public ArticleViewRecord setAllModelColors(SameModelArticleTypeRecord[] value) {
set(30, value);
return this;
}
/**
* Getter for <code>shop.article_view.av_all_model_colors</code>.
*/
@Column(name = "av_all_model_colors")
public SameModelArticleTypeRecord[] getAllModelColors() {
return (SameModelArticleTypeRecord[]) get(30);
}
// -------------------------------------------------------------------------
// Constructors
// -------------------------------------------------------------------------
/**
* Create a detached ArticleViewRecord
*/
public ArticleViewRecord() {
super(ArticleView.ACTIVE_ARTICLE_VIEW);
}
/**
* Create a detached, initialised ArticleViewRecord
*/
public ArticleViewRecord(Long article_id, Long article_model_id, String article_name, String article_name_for_url, Season article_season, Short article_year, Boolean article_standard_size_designation, String article_ean13, String article_config_sku, JsonElement article_features, Color article_color, Color article_color2, Color article_color3, JsonElement article_color_detail, LocalizedMoneyRecord[] article_paid_price, LocalizedMoneyRecord[] article_price, String[] article_image_filenames, Timestamp article_active_from, Discount article_discount, Short brand_id, String brand_name, String brand_name_for_url, BrandCountry brand_country, String brand_logo_url, JsonElement brand_facts, Long commodity_group_id, String commodity_group_name, String commodity_group_name_for_url, CategoryTypeRecord[] categories, ArticleSimpleTypeRecord[] sizes, SameModelArticleTypeRecord[] all_model_colors) {
super(ArticleView.ACTIVE_ARTICLE_VIEW);
set(0, article_id);
set(1, article_model_id);
set(2, article_name);
set(3, article_name_for_url);
set(4, article_season);
set(5, article_year);
set(6, article_standard_size_designation);
set(7, article_ean13);
set(8, article_config_sku);
set(9, article_features);
set(10, article_color);
set(11, article_color2);
set(12, article_color3);
set(13, article_color_detail);
set(14, article_paid_price);
set(15, article_price);
set(16, article_image_filenames);
set(17, article_active_from);
set(18, article_discount);
set(19, brand_id);
set(20, brand_name);
set(21, brand_name_for_url);
set(22, brand_country);
set(23, brand_logo_url);
set(24, brand_facts);
set(25, commodity_group_id);
set(26, commodity_group_name);
set(27, commodity_group_name_for_url);
set(28, categories);
set(29, sizes);
set(30, all_model_colors);
}
}
问题的可能来源
我按照来自 Andrew Rueckert 的链接进行了调试,但问题似乎出在 jOOQ 中。它无法正确处理类型内部的类型。
View 包含一个 ArticleSimpleTypeRecord
那是 PostgreSQL 类型。它有一个内部类型。在类 DefaultBinding
中执行的步骤是:
方法 pgFromString
使用 ArticleSimpleTypeRecord
的默认转换器调用.这意味着调用了以下指令:
else if (Record.class.isAssignableFrom(type)) { 返回(T)pgNewRecord(类型,空,字符串);
方法 pgNewRecord
尝试通过调用以下方法从给定对象创建记录:
public Record operate(Record record) {
List<String> values = PostgresUtils.toPGObject(object.toString());
Row row = record.fieldsRow();
for (int i = 0; i < row.size(); i++) {
pgSetValue(record, row.field(i), values.get(i));
}
return record;
}
这将使用方法 pgSetValue
将值设置到记录中和来自 object
的值.
在设置 json
的值时值 jOOQ 调用方法 pgSetValue(Record record, Field<T> field, String value)
它调用方法 pgFromString
使用字段的转换器(即 the PostgresJSONGsonBinding
JSON converter I found on jOOQ website )。问题出在方法内部 pgFromString
.
内部 pgFromString
, 行 Class<T> type = converter.toType()
返回 com.google.gson.JsonElement
,它不受任何默认值的约束,因此它转到行:
else {
Converter<Object, T> c = (Converter<Object, T>) converter;
return c.from(pgFromString(c.fromType(), string));
}
问题来了,因为json转换器应该从pgFromString(c.fromType(), string)
返回的对象开始,把值转成json。 , 但自 c.fromType()
返回 Object
并且在 jOOQ 中没有对象的默认绑定(bind)再次进入默认情况,一次又一次,我们有 StackOverflowException
.
我看了一下那个类的变化,现在的主人似乎已经解决了这个问题。现在有:
else if (type == Object.class) {
return (T) string;
}
然后,我必须等待下一个 jOOQ 次要版本。我希望它快点到来。
最佳答案
您是否为 JsonElement 注册了自定义绑定(bind)?我们也使用 Gson 类型,并且必须执行以下操作:
pom.xml(缩写)
<plugin>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen-maven</artifactId>
<version>${jooq.version}</version>
<configuration>
<generator>
<database>
<forcedTypes>
<forcedType>
<name>GsonJson</name>
<userType>com.google.gson.JsonElement</userType>
<binding>com.mycompany.dao.bindings.GsonJsonBinding</binding>
<types>json</types>
</forcedType>
</forcedTypes>
</database>
</generator>
</configuration>
</plugin>
GsonJsonBinding.java
public class GsonJsonBinding extends GenericStringlikeBinding<JsonElement> {
public GsonJsonBinding() {
super("json", new JsonConverter());
}
}
JsonConverter.java
public class JsonConverter implements Converter<Object, JsonElement> {
private static final Gson gson = new Gson();
@Override
public JsonElement from(Object t) {
return t == null ? null : gson.fromJson("" + t, JsonElement.class);
}
@Override
public Object to(JsonElement u) {
return u == null || u == JsonNull.INSTANCE ? null : gson.toJson(u);
}
@Override
public Class<Object> fromType() {
return Object.class;
}
@Override
public Class<JsonElement> toType() {
return JsonElement.class;
}
}
关于postgresql - 从选择中获取时的 jOOQ 和 StackOverflowException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39735556/
我需要您在以下方面提供帮助。近一个月来,我一直在阅读有关任务和异步的内容。 我想尝试在一个简单的 wep api 项目中实现我新获得的知识。我有以下方法,并且它们都按预期工作: public Htt
我的可执行 jar 中有一个模板文件 (.xls)。不需要在运行时我需要为这个文件创建 100 多个副本(稍后将唯一地附加)。用于获取 jar 文件中的资源 (template.xls)。我正在使用
我在查看网站的模型代码时对原型(prototype)有疑问。我知道这对 Javascript 中的继承很有用。 在这个例子中... define([], function () { "use
影响我性能的前三项操作是: 获取滚动条 获取偏移高度 Ext.getStyle 为了解释我的应用程序中发生了什么:我有一个网格,其中有一列在每个单元格中呈现网格。当我几乎对网格的内容做任何事情时,它运
我正在使用以下函数来获取 URL 参数。 function gup(name, url) { name = name.replace(/[\[]/, '\\\[').replace(/[\]]/,
我最近一直在使用 sysctl 来做很多事情,现在我使用 HW_MACHINE_ARCH 变量。我正在使用以下代码。请注意,当我尝试获取其他变量 HW_MACHINE 时,此代码可以完美运行。我还认为
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 关闭 9 年前。 要求提供代码的问题必须表现出对所解决问题的最低限度的理解。包括尝试过的解决方案、为什么
由于使用 main-bower-files 作为使用 Gulp 的编译任务的一部分,我无法使用 node_modules 中的 webpack 来require 模块code> dir 因为我会弄乱当
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 5 年前。 Improve this qu
我使用 Gridlayout 在一行中放置 4 个元素。首先,我有一个 JPanel,一切正常。对于行数变大并且我必须能够向下滚动的情况,我对其进行了一些更改。现在我的 JPanel 上添加了一个 J
由于以下原因,我想将 VolumeId 的值保存在变量中: #!/usr/bin/env python import boto3 import json import argparse import
我正在将 MSAL 版本 1.x 更新为 MSAL-browser 的 Angular 。所以我正在尝试从版本 1.x 迁移到 2.X.I 能够成功替换代码并且工作正常。但是我遇到了 acquireT
我知道有很多关于此的问题,例如 Getting daily averages with pandas和 How get monthly mean in pandas using groupby但我遇到
This is the query string that I am receiving in URL. Output url: /demo/analysis/test?startDate=Sat+
我正在尝试使用 javascript 中的以下代码访问 Geoserver 层 var gkvrtWmsSource =new ol.source.ImageWMS({ u
API 需要一个包含授权代码的 header 。这就是我到目前为止所拥有的: var fullUrl = 'https://api.ecobee.com/1/thermostat?json=\{"s
如何获取文件中的最后一个字符,如果是某个字符,则删除它而不将整个文件加载到内存中? 这就是我目前所拥有的。 using (var fileStream = new FileStream("file.t
我是这个社区的新手,想出了我的第一个问题。 我正在使用 JSP,我成功地创建了 JSP-Sites,它正在使用jsp:setParameter 和 jsp:getParameter 具有单个字符串。
在回答 StoreStore reordering happens when compiling C++ for x86 @Peter Cordes 写过 For Acquire/Release se
我有一个函数,我们将其命名为 X1,它返回变量 Y。该函数在操作 .on("focusout", X1) 中使用。如何获取变量Y?执行.on后X1的结果? 最佳答案 您可以更改 Y 的范围以使其位于函
我是一名优秀的程序员,十分优秀!