JPA(休眠)onetomany关系(JPA (hibernate) onetomany relation)
我不确定我想要做什么双向onetomany关系(休眠引擎)。 域模型的缩小版本:
class Person { @OneToMany(mappedBy="personFrom", cascade = CascadeType.PERSIST) public List<Relationship> relationships; } class Relationship { @ManyToOne public Person personFrom; @ManyToOne public Person personTo; }
一些观察结果:
1.使用上面的映射,没有创建连接表。
2.当我删除mappedBy(@OneToMany(cascade = CascadeType.PERSIST))时,创建了连接表,我可以通过Person持久保存。 “personFrom”字段为空,但我认为这是正常的,因为通过连接表维护关系。我也尝试通过在关系中指定连接列,没有任何区别。 任何帮助,高度赞赏。 谢谢。
编辑:1
根据Dan的评论,如果看到域类的完整内容很重要,我已在下面进行了扩展。
class Relationship extends Model{ @ManyToOne public RelationshipType relationshipType; @ManyToOne public Person personFrom; @ManyToOne public Person personTo; @ManyToOne public Person createdBy; @ManyToOne public Role roleFrom; @ManyToOne public Role roleTo; @Override public String toString() { return relationshipType.toString(); } } class Person extends Model { public Date dateCreated; @Lob public String description; @OneToMany(cascade = CascadeType.ALL) public List<Role> roles; @OneToMany(mappedBy="personFrom", cascade = CascadeType.PERSIST) public List<Relationship> relationships; }
角色也与Person有关,但我认为保持personFrom,personTo有助于优化我的查询。
Role extends Model { @ManyToOne public RoleType roleType; @ManyToOne public Person createdBy; }
I am not sure what I am missing to make a bidirectional onetomany relationship (hibernate engine). A scaled down version of the domain model:
class Person { @OneToMany(mappedBy="personFrom", cascade = CascadeType.PERSIST) public List<Relationship> relationships; } class Relationship { @ManyToOne public Person personFrom; @ManyToOne public Person personTo; }
Some of the observations:
1. with the above mapping, there is no join table created.
2. When I remove the mappedBy (@OneToMany(cascade = CascadeType.PERSIST) ), the join table is created and i could persist Relationship through Person. "personFrom" field is empty, but I think that is normal as the relation is maintained through the join table.I also tried by specifying join column at Relationship, didn't make any difference. Any help, highly appreciated. thanks.
Edit:1
As per Dan's comment, if it matters to see the full content of the domain class, I have expanded them below.
class Relationship extends Model{ @ManyToOne public RelationshipType relationshipType; @ManyToOne public Person personFrom; @ManyToOne public Person personTo; @ManyToOne public Person createdBy; @ManyToOne public Role roleFrom; @ManyToOne public Role roleTo; @Override public String toString() { return relationshipType.toString(); } } class Person extends Model { public Date dateCreated; @Lob public String description; @OneToMany(cascade = CascadeType.ALL) public List<Role> roles; @OneToMany(mappedBy="personFrom", cascade = CascadeType.PERSIST) public List<Relationship> relationships; }
Role also related to Person, but I think keeping the personFrom, personTo helps to optimize my queries.
Role extends Model { @ManyToOne public RoleType roleType; @ManyToOne public Person createdBy; }
原文:https://stackoverflow.com/questions/3346154
最满意答案
我认为你所描述的“iframe”是一个“内容加载项”,它是一个矩形控件而不是幻灯片画布,可以显示你的HTML / JS UI。 今天无法从任务窗格上的按钮插入这些内容。 如果您需要这种“iframe”,只需编写内容加载项:您的用户可以根据需要为每张幻灯片插入此内容加载项的多个实例。
如果您今天需要幻灯片中的任务窗格和 Web内容,则需要编写(并发送)两个单独的加载项:一个用于任务窗格“shape”,另一个用于内容“shape”。
I think the "iframe" you're describing is a "content add-in", which is a rectangular control than goes on the slide canvas and can show your HTML/JS UI. It's not possible to insert these from a button on the task pane today. If you need this kind of "iframe", simply write a content add-in: your users can insert as many instances of this content add-in as they want per slide.
If you need a task pane and web content in the slide today, then it's necessary to write (and ship) two separate add-ins: one for the task pane "shape" and the other for the content "shape".
相关问答
更多-
在Office Online中测试加载项的推荐方法(在本例中,在PowerPoint Online中是使用Office 365或SharePoint中的加载项“目录”。以下是Office Online调试的说明 。 而且,正如Igaud所指出的,测试的一个原因是并非所有API都存在于两个地方。 另一个原因是Chrome / Firefox / Safari可能会略微改变您的页面,因此确保UI仍然正确非常重要。 The recommended way to test your add-in in Office ...
-
影响SharePoint Online中内容中的iFrame CSS(Affect iFrame CSS from within content in SharePoint Online)[2022-09-22]
类ms-dlgTitleBtns的有问题的元素位于托管页面上,而不是在表单本身上; 将自定义脚本/ CSS放在同一页面上可以避免通过iframe修改不同页面上的内容。 您可以将JavaScript / CSS添加到打开对话框的页面,而不是将其添加到表单本身。 (确保在实施更改后正确刷新app.js文件。) The problematic element with the class ms-dlgTitleBtns is located on the hosting page, rather than on ... -
任务窗格栏可以将iFrame元素插入到Powerpoint Online吗?(Can task pane bars insert iFrame elements into Powerpoint Online?)[2023-08-01]
我认为你所描述的“iframe”是一个“内容加载项”,它是一个矩形控件而不是幻灯片画布,可以显示你的HTML / JS UI。 今天无法从任务窗格上的按钮插入这些内容。 如果您需要这种“iframe”,只需编写内容加载项:您的用户可以根据需要为每张幻灯片插入此内容加载项的多个实例。 如果您今天需要幻灯片中的任务窗格和 Web内容,则需要编写(并发送)两个单独的加载项:一个用于任务窗格“shape”,另一个用于内容“shape”。 I think the "iframe" you're describing ... -
你正在看到预期的行为。 内容加载项在用户切换到幻灯片放映时重新加载。 有一个解决方法。 每次您的加载项导航到新页面时,都将URL存储在“设置”中。 每次加载项加载时,使用document.getActiveViewAsync( https://dev.office.com/reference/add-ins/shared/document.getactiveviewasync )方法获取当前模式。 如果当前模式是幻灯片放映,请立即重定向到存储在设置中的URL。 我认为任何“状态”信息都必须存储。 You a ...
-
Powerpoint AddIn(Powerpoint AddIn)[2022-08-02]
CustomTaskPanes集合是ThisAddIn类的属性。 因此,您可以使用“this”在ThisAddIn_Startup方法中访问它。 句法。 如果您没有在intellisense / autocomplete中看到该集合。 这个问题可能是由于某些可能性引起的: 您没有使用VSTO(Visual Studio Tools for Office)2005 SE。 您使用的是VSTO 2005 SE,但是您安装的是之前未完全删除的VSTO v3 CTP。 您正在为不支持自定义任务窗格的应用程序(所有O ... -
如何自动加载iframe元素(How to autoload iframe elements)[2023-08-16]
我在这里引用这些信息。 如果我理解你的想法,那看起来很有希望。 友好的iframe 这种技术适用于广告。 这不是一种真正的iframe加载技术,而是一种使用iframe来保存广告的方法。 神奇不在于iframe的加载方式,而在于主页,iframe和广告代码如何协同工作。 它的工作原理如下: 创建一个iframe。 将源设置为来自同一域的小型静态html页面 在iframe中,设置JavaScript变量inDapIF = true以告知广告它是在友好的iframe中加载的 在iframe中,创建一个以广告网 ... -
这不支持。 允许将JS嵌入到PPT中将会带来太多的安全隐患。 根据具体情况,您可以使用Web加载项来处理这种情况。 加载项可以与通用后端进行通信; 允许您在两种环境之间有效地传递信息。 This isn't supported. Allowing JS to be embedded within the PPT would simply present too many security concerns. Depending on the exact scenario, you might be able ...
-
Girish Raja提供了有关如何通过BCS集成CRM Online和SharePoint Point的精彩概述。 他的MSDN博客文章包含了他5月份TechEd视频演示的链接(视频中的第35分钟)以及源代码/说明的链接。 他的演示使用SharePoint内部部署,但提到一旦启用BCS,它将与SharePoint Online一起使用。 (它现在是)。 Girish Raja provides a great overview on how to integrate CRM Online and Shar ...
-
当定义valid_elements时,iframe不在tinymce中工作(iframe not working in tinymce when valid_elements defined)[2022-02-26]
它不是valid_elements and/or extended_valid_elements的问题,它的语法错误。 plugins: [ "code", "media" ] 它应该如下所示,插件用空格分隔 plugins:"code autolink", http://www.tinymce.com/wiki.php/Configuration:plugins 如果启用media插件,它不支持iframe 例如: http : //jsfiddle.net/ug247bsm/7/ I ... -
Python将图像插入现有PowerPoint的中间(Python Insert Image into the middle of an existing PowerPoint)[2023-04-07]
我对这个模块并不熟悉,但我看了他们的快速入门 from pptx.util import Inches from pptx import Presentation def open_PowerPoint_Presentation(oldFileName, newFileName, img, left, top): prs = Presentation(oldFileName) slide = prs.slides[3] pic = slide.shapes.add_picture( ...