有没有人有hibernate 4的功能cfg文件示例?我在网上找到的所有参考文献都是低于v4,但是不起作用.我尝试粘贴我的文件的内容,但这个网站删除了hibernate配置标记.
所以这是出来的:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD//EN"
"http://www.hibernate.org/dtd/">
<hibernate-configuration xmlns="http://www.hibernate.org/xsd/hibernate-configuration">
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<!-- Assume test is the database name -->
<property name="hibernate.connection.url">jdbc:mysql://localhost/foampile</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password"></property>
<!-- List of XML mapping files -->
<mapping resource="SiteRecord.hbm.xml"/>
</session-factory>
</hibernate-configuration>
Run Code Online (Sandbox Code Playgroud)
一旦我改变了
<hibernate-configuration xmlns="http://www.hibernate.org/xsd/hibernate-configuration"
xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-configuration hibernate-configuration-4.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
Run Code Online (Sandbox Code Playgroud)
我得到这个例外:
Caused by: org.xml.sax.SAXParseException; lineNumber: 9; columnNumber: 63; Attribute "xmlns" must be declared for element type "hibernate-configuration".
Run Code Online (Sandbox Code Playgroud)
但是指定了xmlns(xmlns ="http://www.hibernate.org/xsd/hibernate-configuration")
这是HIBERNATE 4.1中的一个BU ???
我很好奇是否在同一行代码中打包多个和/或嵌套方法调用对性能更好,这就是为什么一些开发人员这样做,代价是使代码的可读性降低.
例如
//like
Set<String> jobParamKeySet = jobParams.keySet();
Iterator<String> jobParamItrtr = jobParamKeySet.iterator();
Run Code Online (Sandbox Code Playgroud)
也可以写成
//dislike
Iterator<String> jobParamItrtr = jobParams.keySet().iterator();
Run Code Online (Sandbox Code Playgroud)
就个人而言,我讨厌后者,因为它在同一行中进行了多次评估,并且我很难阅读代码.这就是为什么我试图通过各种方式避免每行代码进行多次评估.我也不知道,jobParams.keySet()返回Set和我的错误.
另一个例子是:
//dislike
Bar.processParameter(Foo.getParameter());
Run Code Online (Sandbox Code Playgroud)
VS
//like
Parameter param = Foo.getParameter();
Bar.processParameter(param);
Run Code Online (Sandbox Code Playgroud)
前者让我感到有毒和头晕,因为我喜欢在每行代码中使用简单而干净的评估,当我看到其他人编写的代码时,我就讨厌它.
但是在同一行中打包多个方法调用有什么(性能)好处吗?
编辑:由于@stemm提醒,单线程也更难调试
我正在寻找在Perl中获取文件校验和的方法,但不是通过执行系统命令cksum- 想在Perl本身中这样做,因为脚本需要在UNIX和Windows之间移植.cksum <FILENAME> | awk '{ print $1 }'适用于UNIX,但显然不适用于Windows.我已经探索过MD5但是看起来像获取文件句柄似乎是必要的,并且通常它似乎不是一种非常紧凑的方式来获取该数据(一线优选).
有没有更好的办法?
我试图通过分隔符将一个字符串拆分成一个列表(让我们说,),但是在我的特定情况下,只有当它没有包裹在某个模式中时,才应将分隔符视为分隔符<>.IOW,当嵌入逗号时<>,它将被忽略为分隔符,变成一个不被分隔的常规字符.
所以,如果我有以下字符串:
"first token, <second token part 1, second token part 2>, third token"
Run Code Online (Sandbox Code Playgroud)
它应该分成
list[0] = "first token"
list[1] = "second token part 1, second token part 2"
list[2] = "third token"
Run Code Online (Sandbox Code Playgroud)
不用说,我不能只是做一个简单的分裂,,因为这将第二令牌拆分成两个标记,second token part 1并且second token part 2,因为他们有一个逗号在它们之间.
我应该如何定义使用它的模式Python RegEx?
这不是一个编程问题,而是关于惯例.什么是Reply 'Done'传统上的意思为只是一种替代Reply,以在代码审查评论Gerrit?
这是否意味着我同意你的意见并将在本地完成或者在本地完成或者是否意味着我根据您的建议修改了更改?因为如果我修改了更改并将其推送到同一个Gerrit评论中,那么发表评论的最新文件修订将覆盖之前的所有评论将会消失(至少这是我的经验).
我想知道是否可以ctags使用从Java方法中提取类使用.到目前为止,我只能使用它来获取方法和实例变量的列表,但不能在方法中使用哪些类.
例如
...
public void doSomething(MyClass myClassInst) {
int someVar = myClassInst.getSomeVar();
System.out.println("Some var is " + someVar);
}
...
Run Code Online (Sandbox Code Playgroud)
现在,我得到的是对方法声明的认可.但我想提取的是,doSomething它也使用了类MyClass,System但不仅仅是解析文本,还要知道包括包(java.lang.System和com.mypackage.MyClass)在内的完整类地址.
为了能够提取这种元数据,ctags需要访问编译器abstract syntax tree,我不确定它是否这样做,或者它只是对源代码进行文本解析.
有没有办法完成我尝试使用ctags做的事情,或者它是否超出了它的功能范围?
这似乎是一个愚蠢的问题,但这个页面没有指定如何在IntelliJ中实际打开一个允许你安装插件的屏幕.社区版甚至可以吗?
我认为git push --force它只会推送当前分支,但它会推送所有分支。真正的损坏只对我同事的几个分支造成,我已经很长时间没有拉动了,因此,通过这样做(由 启用--force),我完全重置了自我以来在远程上所做的所有提交。最后拉。
如果我没有去找我的同事要求他们推送最新的当地分支机构来GitHub消除我造成的损害,我能做些什么来消除它吗?不幸的是,我所做的相当于git reset --hard,这意味着我取消了此后的所有提交。有什么办法可以撤销吗?
SQLGrammarException当我将空集设置为SQL IN参数时,我的代码会导致:
Query query = this.entMngr.createNativeQuery("SELECT foo_id, first, last FROM foo WHERE bar IN :barSet");
//barSet is a Set<Integer>
query.setParameter("barSet", barSet);
//this throws exception
List<Object> nativeList = query.getResultList();
Run Code Online (Sandbox Code Playgroud)
当集合不为空时,一切都有效.我怎样才能确定是否填充了集合(或任何集合提交)?
有没有办法getElementsByTagName只在单个节点级别使用而不是递归?
例如,考虑解析pom.xml文件:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>com.parent</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>2.0.0</modelVersion>
<groupId>com.parent.somemodule</groupId>
<artifactId>some_module</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>Some Module</name>
...
Run Code Online (Sandbox Code Playgroud)
如果我想进入groupId顶级(特别是project->groupId,不是project->parent->groupId),我使用:
xmldoc = minidom.parse('pom.xml')
groupId = xmldoc.getElementsByTagName("groupId")[0].childNodes[0].nodeValue
Run Code Online (Sandbox Code Playgroud)
但不幸的是,groupId无论层次结构级别如何,它都会在文件中找到第一个物理事件project->parent->groupId.我实际上只想在特定节点级别进行非递归查找,而不是在其子级内.有没有办法做到这一点xml.dom?
更新: 我切换到BeautifulSoup但仍然有隐式递归遍历的相同问题:使用BeautifulSoup在Python中查找非递归DOM子节点