我正在使用Hibernate 3.1.1,特别是我正在使用HQL查询.
根据文档,Hibernate的查询是多态的:
像这样的查询:
from Cat as cat
不仅返回实例Cat
,而且返回子类的实例DomesticCat
.
如何查询Cat的实例,而不查询其子类的实例?
我希望能够在不必明确提及每个子类的情况下完成它.
我知道以下选项,但发现它们并不令人满意:
Hibernate允许用户决定查询是否应该是多态的,这是有意义的,但我找不到这样的选项.
提前致谢!
我已经上班了几个小时,在网上寻找解决方案.我可以高兴地说,这真的让我生气了.
打开"安装新软件"后,我收到"'联系软件站点'时遇到了问题.
现在可以找到一些网站.有关更多详细信息,请参阅错误日志."
这是错误日志:
有些网站无法找到.有关详细信息,请参阅错误日志.无法在http://download.eclipse.org/webtools/repository/indigo/content.xml上读取存储库 .无法分配请求的地址:JVM_Bind无法在http://download.eclipse.org/eclipse/updates/3.7/content.xml中读取存储库 .无法分配请求的地址:JVM_Bind无法在http://download.eclipse.org/mylyn/releases/indigo/content.xml上读取存储库 .无法分配请求的地址:JVM_Bind无法在http://download.eclipse.org/releases/indigo/content.xml上读取存储库 .无法分配请求的地址:JVM_Bind
有任何想法吗?我想安装MercurialEclipse但它找不到存储库,默认情况下也是如此.
我想知道如何获取在预提交钩子上提交的文件列表.
如果该列表不包含特定路径中的特定文件,那么我想拒绝提交.
我有以下带有许多属性的XML标记.没有给出属性的数量/名称,因为我在运行时获取XML,而我只知道标记的名称.如何使用JAXB将所有属性作为一个Map<String, String>
?
如何将其添加到以下Java代码中:
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "script ")
@XmlAccessorType(javax.xml.bind.annotation.XmlAccessType.FIELD)
public class SearchScriptElement
{
@XmlAttribute(name = "script")
private String script = "";
public String getScript()
{
return name;
}
public void setScript(String name)
{
this.name = name;
}
}
Run Code Online (Sandbox Code Playgroud)
XML示例:我可以拥有许多在运行时未知的属性:
<ScriptList>
<script name="xxx" value="sss" id=100 >
<script>
<script name="xxx" value="sss" id=100 alias="sss">
<script>
</ScriptList>
Run Code Online (Sandbox Code Playgroud) 我想我过去没有看到过这样的事情.
我的锁没有持有独占锁,当创建对象的新实例时,tryLock
返回true,另一个TimerTask
被安排.
public class A {
private static Timer timer = new Timer();
private static Lock clean_lock = new ReentrantLock();
private static ConcurrentHashMap<String,B> _b_dict = new ConcurrentHashmap<String,B>();
public A() {
if(clean_lock.tryLock()) {
timer.scheduleAtFixedRate(new TimerTaskThread(), new Date(), 60000);
}
}
//Various NON static methods
// use an iterator at one point so they must be NON static
class TimerTaskThread extends TimerTask {
public void run() {
//delete old stuff in _b_dict
}
}
}
//sample usage
public …
Run Code Online (Sandbox Code Playgroud) 我在使用DecimalFormat时遇到了最奇怪的事情.
我在webapplication中使用它.我设置了一些测试,它在本地继续失败.我的一个朋友运行它,他能够成功运行JUnit测试.
奇怪的是,在我们的服务器上,应用程序运行完美,没有任何问题.
可能是Java依赖于valuta和数字设置等系统设置?或者还有其他原因吗?这就是我的代码片段:
public String generateFormatPrice(double price) throws Exception {
DecimalFormat format1 = new DecimalFormat("#,##0.00");
String tmp = format1.format(price).replace(".", "&");
String[] tmps = tmp.split("&");
return tmps[0].replace(',', '.') + "," + tmps[1];
}
Run Code Online (Sandbox Code Playgroud)
非常感谢提前!