这在Java中是可能的:
package x;
public class X {
// How can this method be public??
public Y getY() {
return new Y();
}
}
class Y {}
Run Code Online (Sandbox Code Playgroud)
那么Java编译器允许我将该getY()方法声明为什么是一个很好的理由public?困扰我的是:类Y是包私有的,但访问者getY()在方法签名中声明它.但是在x包之外,我只能将方法的结果分配给Object:
// OK
Object o = new X().getY();
// Not OK:
Y y = new X().getY();
Run Code Online (Sandbox Code Playgroud)
好.现在我可以试着用一个例子来构建一个例子,可以用方法结果协方差来解释.但为了让事情变得更糟,我也可以这样做:
package x;
public class X {
public Y getY(Y result) {
return result;
}
}
class Y {}
Run Code Online (Sandbox Code Playgroud)
现在我永远无法getY(Y result)从x …
对于Oracle 11.2.0.2.0中对大量数据进行中型查询的查询执行计划,我遇到了一些问题.为了加快速度,我引入了一个范围过滤器,其大致类似于:
PROCEDURE DO_STUFF(
org_from VARCHAR2 := NULL,
org_to VARCHAR2 := NULL)
-- [...]
JOIN organisations org
ON (cust.org_id = org.id
AND ((org_from IS NULL) OR (org_from <= org.no))
AND ((org_to IS NULL) OR (org_to >= org.no)))
-- [...]
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,我想限制JOIN的organisations使用数量组织的可选范围.客户端代码可以调用DO_STUFF(假设是快速)或没有(非常慢)限制.
问题是,PL/SQL将为上面org_from和org_to参数创建绑定变量,这在大多数情况下是我所期望的:
-- [...]
JOIN organisations org
ON (cust.org_id = org.id
AND ((:B1 IS NULL) OR (:B1 <= org.no))
AND ((:B2 IS NULL) OR (:B2 >= org.no)))
-- [...] …Run Code Online (Sandbox Code Playgroud) 在我的Java代码中,我有这样的东西:
ResultSet rs = statement.executeQuery(
"SELECT a,b,c FROM foo -- here starts the long query"+
" -- that is not yet finished " +
" -- that still has something to say... "+
" -- now the end !"
);
Run Code Online (Sandbox Code Playgroud)
我想像这样清理我的代码:
ResultSet rs = statement.executeQuery(all_queries.getQuery("The very long one"));
Run Code Online (Sandbox Code Playgroud)
我读过那ResourceBundle是为了本地化.所以我不认为它符合我的情况.
应该all_queries是什么?
编辑: 对我来说最重要的是清理代码.
当模态元素一个放在另一个上面时,Android Webkit浏览器(在2.2,2.3和3.0上测试)似乎表现得很奇怪.在这个例子中

...我正在显示一个带有z-index 200 的jQuery UI日期选择器,一个灰色叠加div,跨越整个文档的高度和宽度,使用z-index 199,后面是所有常规表单.
在上面的例子中,我点击了2011年的下拉控件.它没有选择该下拉列表,而是将焦点放在灰色叠加层下面的textarea元素上.
注意:桌面Firefox浏览器或iPhone Webkit浏览器不会发生这种情况.
知道什么是错的吗?或者如何解决这个问题?我想避免修改表单(例如禁用所有元素,而叠加显示)...
With the new java lambdas and the concept of functional interfaces, will it be possible to treat those functional interfaces as methods?
interface Func { void execute(int i); }
void call(Func f)
{
f(1); //instead of f.execute(1);
}
Run Code Online (Sandbox Code Playgroud)
I found a lot of information about the syntax of actual lambda expressions, but nothing about this.
我有一个问题..为什么我重复了我在fetch方法中选择的内容.
Date minDate = getDSLContext()
.select(CON_CAL_INSTANCE.DATE.min())
.from(CON_CAL_INSTANCE)
.join(CON_CAL_TEMPLATES)
.on(CON_CAL_INSTANCE.TEMPLATE_ID.eq(CON_CAL_TEMPLATES.ID))
.where(CON_CAL_TEMPLATES.ENTRY_TYPE.in("REPT", "HRPT"))
.fetchOne(CON_CAL_INSTANCE.DATE.min());
Run Code Online (Sandbox Code Playgroud)
所以我CON_CAL_INSTANCE.DATE.min()在我的select子句中提供了为什么我必须重复它fetchOne(CON_CAL_INSTANCE.DATE.min())?
或者我不是这样做的吗?
PostgreSQL知道一些在其名称中使用问号字符的时髦ASCII艺术运算符,例如这些JSON运算符:
? 字符串是否作为JSON值中的顶级键存在??| 这些数组字符串中是否存在顶级键??& 所有这些数组字符串都作为顶级键存在吗?问题是官方PostgreSQL JDBC驱动程序似乎没有正确解析包含此类运算符的SQL字符串.它假定问号是普通的JDBC绑定变量.以下代码......
try (PreparedStatement s = c.prepareStatement("select '{}'::jsonb ?| array['a', 'b']");
ResultSet rs = s.executeQuery()) {
...
}
Run Code Online (Sandbox Code Playgroud)
...引发异常:
org.postgresql.util.PSQLException: Für den Parameter 1 wurde kein Wert angegeben.
at org.postgresql.core.v3.SimpleParameterList.checkAllParametersSet(SimpleParameterList.java:225)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:190)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:424)
at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:161)
at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:114)
Run Code Online (Sandbox Code Playgroud)
我该如何使用此运算符?
我有一个小问题,有没有办法动态包含另一个xsl?例如:
<xsl:variable name="PathToWeb" select="'wewe'"/>
<xsl:include href="http://{$PathToWeb}/html/xsl/head.xsl" />
<xsl:include href="http://{$PathToWeb}/html/xsl/navigation.xsl" />
<xsl:include href="http://{$PathToWeb}/html/xsl/promo.xsl" />
<xsl:include href="http://{$PathToWeb}/html/xsl/3columns.xsl" />
<xsl:include href="http://{$PathToWeb}/html/xsl/footer.xsl" />
Run Code Online (Sandbox Code Playgroud) 我真的很困惑,列结果集映射如何工作?当我使用列而不是实体时,我映射的是什么?看看这个例子......
Query q = em.createNativeQuery(
"SELECT o.id AS order_id, " +
"o.quantity AS order_quantity, " +
"o.item AS order_item, " +
"i.name AS item_name, " +
"FROM Order o, Item i " +
"WHERE (order_quantity > 25) AND (order_item = i.id)",
"OrderResults");
@SqlResultSetMapping(name="OrderResults",
entities={
@EntityResult(entityClass=com.acme.Order.class, fields={
@FieldResult(name="id", column="order_id"),
@FieldResult(name="quantity", column="order_quantity"),
@FieldResult(name="item", column="order_item")})},
columns={
@ColumnResult(name="item_name")}
)
Run Code Online (Sandbox Code Playgroud)
我可以理解他在这里要做的是什么,实体结果将是他想要的结果集,字段将尝试将字段映射到别名,列结果到底是做什么的?它看起来不像是映射到任何东西.
例如,我有这样的数据:
Group Money
A 100
A 200
B 100
B 300
B 110
Run Code Online (Sandbox Code Playgroud)
我想使用GROUP BY(其他东西)来总结我的数据,如下所示:
Group Money Average Count
A 300 150 2
B 510 170 3
C 810 162 5
Run Code Online (Sandbox Code Playgroud)
哪个C组表示A组和B组
有没有办法以某种简单的方式得到结果?