我知道hibernate是JPA的一个实现,也有自己的特性.我正在尝试使用带有注释的hibernate,但我发现我必须在包"javax.persistence.*"下使用一些注释,例如:Column,OneToMany,ManyToOne等等.
我不想使用JPA,但是在"org.hibernate.annotations"包下找不到像OneToMany这样的注释.那么,jpa annatations是hibernate的一部分吗?如果我想在jpa中使用hibernate,我必须使用一些"javax.persistence.*"注释?
我正在使用PySide和PyCharm.当我想在编辑器中跳转到PySide类方法的源代码时,它总是告诉我:
Cannot find declaration to go to
Run Code Online (Sandbox Code Playgroud)
我检查了目录python27/Lib/site-packages/PySide,有很多.pyc和.pyd文件,但很少*.py.我也从下载网站PySide源数据包,但也有许多.cpp和.xml文件存在.
我怎样才能找到.pyPySide 的来源并让PyCharm找到它们?或者我必须阅读文档,这不是那么方便.
我在512M vps上运行play2.
它可以创建一个新的应用程序:
play new test
Run Code Online (Sandbox Code Playgroud)
但无法启动该test项目:
cd test
play
Run Code Online (Sandbox Code Playgroud)
它报告了这样一个错误:
[freewind@289144 test]$ play
Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.
[freewind@289144 test]$
Run Code Online (Sandbox Code Playgroud)
经过一些研究,我发现play2将调用play-2.0/framework/build,并build具有以下设置:
我尝试修改play-2.0/playshell,来自:
java ${DEBUG_PARAM} -Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled
-XX:MaxPermSize=384M -Dfile.encoding=UTF8 -Dplay.version="${PLAY_VERSION}"
-Dsbt.ivy.home=`dirname $0`/../repository -Dplay.home=`dirname $0`
-Dsbt.boot.properties=`dirname $0`/sbt/sbt.boot.properties
-jar `dirname $0`/sbt/sbt-launch.jar "$@"
Run Code Online (Sandbox Code Playgroud)
我们可以看到它Xms是512M,vps没有足够的内存.
所以我把它改成:
java ${DEBUG_PARAM} -Xms112M -Xmx300M -Xss1M
-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=84M -Dfile.encoding=UTF8
...
Run Code Online (Sandbox Code Playgroud)
这次,错误消息被更改: …
经过短暂的谷歌搜索,我得不到一个好的答案,所以我在这里问.
通常,当我想格式化当前文件时,我会这样做:
c-x h c-m-\
Run Code Online (Sandbox Code Playgroud)
它格式化当前文件,但我丢失了光标位置.例如,我正在编辑一个长文件,现在我在第157行.当我重新格式化文件时,我发现我的光标跳到了第1行.我要将它手动移动到第157行,这不方便.
我该怎么做?
HTML代码:
<body ng-controller="MainCtrl">
<h1>Hello {{name}}</h1>
<div id="aaa" myd1>
In a directive
</div>
<button ng-click="showDirectiveScope()">Show Directive Scope</button>
</body>
Run Code Online (Sandbox Code Playgroud)
角度代码:
var app = angular.module('angularjs-starter', []);
app.controller('MainCtrl', function($scope,$element) {
$scope.name = 'World';
$scope.showDirectiveScope = function() {
var aaa = $element.find("#aaa");
console.log(aaa);
console.log(angular.element(aaa).scope());
}
});
app.directive('myd1', function(){
return {
scope: true
}
});
Run Code Online (Sandbox Code Playgroud)
页面中将显示"显示指令范围"按钮.当我单击它时,我希望angular找到DOM id=aaa,然后获取并记录它由指令创建的范围myd1.
但它会打印undefined,哪里出错了?
HTML代码:
<div class="test">{{name}}</div>
Run Code Online (Sandbox Code Playgroud)
角度代码:
var app = angular.module('angularjs-starter', []);
app.controller('MainCtrl', function($scope) {
$scope.name = 'World';
});
app.directive('test', function(){
return {
restrict: 'C',
link: function(scope, elm, attrs){
var content = elm.html();
alert(content);
}
}
});
Run Code Online (Sandbox Code Playgroud)
它将提示字符串{{name}}。如何提醒渲染的字符串World?
Scala代码:
val str = "<a>11</a><b>22</b>"
XML.loadString(str)
Run Code Online (Sandbox Code Playgroud)
它会报告例外(当然):
org.xml.sax.SAXParseException:
The markup in the document following the root element must be well-formed.
Run Code Online (Sandbox Code Playgroud)
是否可以从字符串加载NodeSeq?
飞镖代码:
main() {
print(PPP.name);
print(CCC.name);
}
class PPP {
static String name = "PPP";
}
class CCC extends PPP {
}
Run Code Online (Sandbox Code Playgroud)
它打印:
PPP
Unhandled exception:
No static getter 'name' declared in class 'CCC'.
NoSuchMethodError : method not found: 'name'
Receiver: Type: class 'CCC'
Arguments: [...]
Run Code Online (Sandbox Code Playgroud)
因此,无法在Dart中访问父类的静态变量吗?
有一个类型列表List[Option[String]],它可能包含Some或None
val list:List[Option[String]] = List(Some("aaa"), None, Some("bbb"))
list match {
case /*List with all Some*/ => println("all items are Some")
case /*List with all None*/ => println("all items are None")
case /*List with Some and None*/ => println("Contain both Some and None")
}
Run Code Online (Sandbox Code Playgroud)
但我不知道如何写它.是否可以使用模式匹配?
以下代码可以编译:
def hello[T](f: => T) = f
hello(() => 12)
Run Code Online (Sandbox Code Playgroud)
但不是:
def hello(f: => Int) = f
hello(() => 12)
Run Code Online (Sandbox Code Playgroud)
哪个报告错误:
<console>:9: error: type mismatch;
found : () => Int
required: Int
hello(() => 12)
Run Code Online (Sandbox Code Playgroud)
为什么?