首页 \ 问答 \ Hibernate:为什么要使用O / R映射?(Hibernate: why use O/R mapping?)

Hibernate:为什么要使用O / R映射?(Hibernate: why use O/R mapping?)

我是Hibernate的新手。

1)我不太明白为什么我们需要在* .hbm.xml文件中指定O / R映射关系,或者在数据集中添加“一对一”,“一对多”等注释。 拥有它们是必须的吗? O / R映射关系如何真正在幕后工作?

2)添加* .hbm.xml与databean注释的关系有什么区别? 我们应该两个都做吗? 每个人的优点和缺点是什么?


I'm new to Hibernate.

1) I don't quite understand why we need to specify O/R mapping relationship in *.hbm.xml file or add annotations for "one-to-one", "one-to-many", etc in databeans. Is it a must to have them? How does O/R mapping relationship really work behind the scene?

2) What is the difference between adding relationship to *.hbm.xml and databean annotation? Should we do both? Advantages and disadvantages for each of them?


原文:https://stackoverflow.com/questions/38507803
更新时间:2022-02-15 11:02

最满意答案

代替:

if(currentPosition == numberOfSlides - 1) {
    currentPosition = 0;
} else {
    currentPosition++;
}

您需要将第一张幻灯片移动到最后(并同时调整容器的位置):

if (currentPosition > 0) {
    $('#slidesHolder').css('marginLeft',0)
        .children().first().appendTo('#slidesHolder');
} else {
    currentPosition += 1;
}

http://jsfiddle.net/mblase75/qatry/

或者,为了更好地优化整个事物,您可以消除currentPosition变量和moveSlide子函数,并在.animate方法中使用回调:

function changePosition() {
    $('#slidesHolder').animate({
        'marginLeft': 0-slideWidth
    }, function() {
        $('#slidesHolder').css('marginLeft', 0)
            .children().first().appendTo('#slidesHolder');
    });
}

http://jsfiddle.net/mblase75/8vaCg/


Instead of:

if(currentPosition == numberOfSlides - 1) {
    currentPosition = 0;
} else {
    currentPosition++;
}

You need to move the first slide to the very end (and adjust the position of the container at the same time):

if (currentPosition > 0) {
    $('#slidesHolder').css('marginLeft',0)
        .children().first().appendTo('#slidesHolder');
} else {
    currentPosition += 1;
}

http://jsfiddle.net/mblase75/qatry/

Or, to optimize the whole thing a little more, you can eliminate the currentPosition variable and the moveSlide sub-function, and just use a callback in the .animate method:

function changePosition() {
    $('#slidesHolder').animate({
        'marginLeft': 0-slideWidth
    }, function() {
        $('#slidesHolder').css('marginLeft', 0)
            .children().first().appendTo('#slidesHolder');
    });
}

http://jsfiddle.net/mblase75/8vaCg/

相关问答

更多
  • 答案是,一旦任一个效果被激活,它将从元素中取出内联CSS属性“display = none”。 这些隐藏效果需要将display属性设置为“none”。 所以,只需重新排列方法的顺序,并在渐变和幻灯片之间的链中添加一个css-modifier。 $('#anotherDiv').hover(function() { $('#myDiv').stop(true, true).fadeIn({ duration: slideDuration, queue: false }).css('display', ...
  • 首先你应该包含jQuery库,然后有几个错误(JS和CSS)。 看这里: $(".items .title-bar").on("mouseover", function () { $(this).closest(".items").find(".car-info").slideDown(); //@Vedant Terkar edit }); $(".items .title-bar").on("mouseout", function () { $(this).closest ...
  • UITableView提供了用动画插入和删除行的方法,并为您处理所有的动画。 尝试这样的事情: [tableView beginUpdates]; [tableView deleteRowsAtIndexPaths:myIndexPaths withRowAnimation:UITableViewCellRowAnimationRight]; [tableView endUpdates]; 然后在新的单元格中滑动: [tableView beginUpdates]; [t ...
  • 代替: if(currentPosition == numberOfSlides - 1) { currentPosition = 0; } else { currentPosition++; } 您需要将第一张幻灯片移动到最后(并同时调整容器的位置): if (currentPosition > 0) { $('#slidesHolder').css('marginLeft',0) .children().first().appendTo('#slidesHold ...
  • 这是正确的代码。 经过测试,整洁和工作。 请享用! http://jsfiddle.net/ReuLr/6/ Here is the correct code. Tested, tidy and working. Enjoy! http://jsfiddle.net/ReuLr/6/
  • 查看本教程和示例http://www.queness.com/post/356/create-a-vertical-horizontal-and-diagonal-sliding-content-website-with-jquery 基本上,您必须将CSS和HTML设置为将所需的所有面板/屏幕作为div(行和列)。 然后为每个面板设置一个选择器并绑定一个单击事件[来自链接的代码] 。 $(document).ready(function() { //get all link with class ...
  • 您的动画正在排队,请使用.stop() : jQuery(window).scroll(function () { if (jQuery(this).scrollTop() > 100) { if (jQuery('.totop').hasClass('visible') == false) { jQuery('.totop').stop().animate({ right: '0px' }, funct ...
  • 你在尝试这样的事吗? HTML:

  • 您可以在代码中改进许多内容以实现您的目标。 首先,活动类设置为幻灯片但不应用任何特殊的CSS规则,因为您将position: absolute设置为div,您必须将z-index设置为重叠一个以上,初始化您的应用程序。 这里有一个想法,如何实现你想要的: https://jsfiddle.net/nz2hL6vn/1/ There are many things that you can improve in your code to achieve what you want. First, active ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)