我有一个表包含引用相同表的主键和外键.如何在hibernate中实现这种映射...表的结构如下..
Dept (
deptno pk,
dname,
location
)
employee (
empid pk,
ename,
Manager Id Foregin key references Employee(empid),
deptno Foregin key references dept(deptno),
doj date,
)
Run Code Online (Sandbox Code Playgroud) 使用spring security时,特别是@notation; 在Controller中访问主体的正确方法是什么?让我们说以下是我的控制器,但我想在某个地方访问secure()方法中的主体...
@Controller
public class LoginController {
@RequestMapping(value = "/login", method = RequestMethod.GET)
public String login(ModelMap map, @RequestParam(value="fail" , required=false) String fail){
map.addAttribute("title", "Login: AD Credentials");
if(fail != null){
map.addAttribute("error", "Invalid credentials");
}
return("login");
}
@RequestMapping("/secure")
@PreAuthorize("isAuthenticated()")
public String secure(ModelMap map, String principal){
System.out.println(principal);
return("secure");
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个带有m2eclipse和颠覆性的Eclipse设置.我从svn导入了一个maven2项目.但是我得到的错误信息是缺少一大堆工件(例如:缺少工件org.springframework:spring-test:jar:3.0.1.RELEASE:test).
如果我查看我的存储库,我会在那里看到jar文件但是它们有一个额外的扩展名.lastUpdated.为什么maven追加.last更新到罐子里?更重要的是:我该如何解决这个问题?
在我的POM中没有提到lastUpdated的类型.
我正在创建一个包含StreamWrite的简单类
class Logger
{
private StreamWriter sw;
private DateTime LastTime;
public Logger(string filename)
{
LastTime = DateTime.Now;
sw = new StreamWriter(filename);
}
public void Write(string s)
{
sw.WriteLine((DateTime.Now-LastTime).Ticks/10000+":"+ s);
LastTime = DateTime.Now;
}
public void Flush()
{
sw.Flush();
}
~Logger()
{
sw.Close();//Raises Exception!
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我在析构函数中关闭此StreamWriter时,它引发了StreamWriter已被删除的异常?
为什么?以及如何使其工作,以便在删除Logger类时,StreamWriter在删除之前关闭?
谢谢!
我正在尝试使用HttpService创建一个包,使用maven-bundle-plugin注册Servlet.
该项目的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">
<modelVersion>4.0.0</modelVersion>
<groupId>felix-tutorial</groupId>
<artifactId>example-1</artifactId>
<version>1.0</version>
<packaging>bundle</packaging>
<name>Apache Felix Tutorial Example 1</name>
<description>Apache Felix Tutorial Example 1</description>
<!-- Build Configuration -->
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${pom.groupId}.${pom.artifactId}</Bundle-SymbolicName>
<Bundle-Name>Service listener example</Bundle-Name>
<Bundle-Description>A bundle that displays messages at startup and when service events occur</Bundle-Description>
<Bundle-Vendor>Apache Felix</Bundle-Vendor>
<Bundle-Version>1.0.0</Bundle-Version>
<Bundle-Activator>tutorial.example1.Activator</Bundle-Activator>
<Import-Package>org.osgi.framework;version="1.0.0", javax.servlet, javax.servlet.http</Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<!-- Dependecies Management -->
<dependencies>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.framework</artifactId>
<version>2.0.4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId> …Run Code Online (Sandbox Code Playgroud) 我正在实现一个继承自的自定义控件Control.我希望它是可聚焦的(它是一种列表框).
在构造函数中,我这样做
SetStyle(ControlStyles.Selectable, true);
Run Code Online (Sandbox Code Playgroud)
我现在可以使用Tab导航到控件.
但是,当控件收到鼠标单击时,它不会自动声明焦点.当然,我可以解决这个问题:
protected override void OnMouseDown(MouseEventArgs e)
{
Focus();
base.OnMouseDown(e);
}
Run Code Online (Sandbox Code Playgroud)
但这感觉就像一个不应该是必需的kludge.这真的是要走的路吗?或者有什么方法可以告诉Control您在收到鼠标点击时自动声明焦点?
我有这个href链接文本"attivo"或"non attivo"
用户可以使用ajax请求$ .post()在数据库中将项目设置为"活动"或"关闭"
我有2个问题:
我无法获得$(this)的引用工作..我用普通链接尝试了它并且它可以工作,但是如果/ else没有包装?
如何防止用户在链接上多次单击并提交多个请求?这是一个有效的问题吗?我需要某种小型计时器吗?
首先,我正在考虑一个javascript确认消息,但这对此功能来说非常烦人.
HTML:
<dl id='album-list'>
<dt id="dt-2">some title</dt>
<dd id="dd-2">
some description<br />
<div class='links-right'>status: <a class='toggle-active' href='#'>non attivo</a></div>
</dd>
</dl>
<a class="test" href="#">test</a>
Run Code Online (Sandbox Code Playgroud)
JS:
$('dd a.toggle-active').click(function() {
var a_ref = $(this);
var id = a_ref.parent().parent().attr('id').substring(3);
if (a_ref.text() == "non attivo") {
var new_active = "active"; // for db in english
$.post("ajax-aa.php", {album_id:id, album_active:new_active},
function(data) {
// alert("success");
a_ref.text("non attivo"); // change href text
});
} else {
var new_active = "closed"; // …Run Code Online (Sandbox Code Playgroud) 我已经设置了一个jQuery可排序列表,但是我需要能够将可排序的"固定"中的一些项目保留在原位,并且其他项目可以对它们进行排序.我认为会有内置的方法来实现这一点,唉,事实并非如此.
我可以设置列表而不包括有问题的项目:
<ul id="fruit">
<li class="fixed">apples</li>
<li>oranges</li>
<li>bananas</li>
<li>pineapples</li>
<li>grapes</li>
<li class="fixed">pears</li>
<li>mango</li>
</ul>
<script type="text/javascript">
$('#fruit').sortable({items: "li:not('.fixed')"})
</script>
Run Code Online (Sandbox Code Playgroud)
这使我无法拖放这些项目,但如果对它们周围的项目进行排序,它们仍会移动.可能有一种方法可以使用此方法具有的许多回调来执行此操作但我无法解决此问题.
也许这种方法可以成为UI Sortable选项的一个很好的补充?
我希望能够找出用户在浏览器中当前选择的文本中存在哪些DOM元素.
document.getSelection()会为我们提供当前选中的文本.但是,我们如何确定此文本选择中包含哪些DOM元素?