小编msa*_*gel的帖子

每个实体休眠两个表

我有一个实体 - User.它由描述User.class.

Hibernate为每个实体创建一个表,所以当我调用时session.save(user),我的数据总是保存到该表中.

现在我需要另一个表来表示相同User类型的数据,我需要将我的实体保存到该表中.

数据结构(类似这样):

table users_1_table{
  string id;
  string username;
}

table users_2_table{
  string id;
  string username;
}
Run Code Online (Sandbox Code Playgroud)

使用这个:

session.save(user1,"users_1_table")
session.save(user2,"users_2_table")
Run Code Online (Sandbox Code Playgroud)

和结果,我应该user1users_1_tableuser2users_2_table.

由于系统限制,我不能将这两个对象放在一个表中.(即使创建额外的字段也是个坏主意).

我可以在没有子类化的情况下这样做吗?使用programmaticaly hibernate配置?

java sqlite spring hibernate hibernate-annotations

16
推荐指数
1
解决办法
3万
查看次数

拆分Android应用程序分为两部分

我试图了解是否可以将Android应用程序拆分为两部分(从一个APK安装).我调查这个是在Device存储器上安装一个部件而在SD-CARD上安装另一个部件.这两个部分属于一起,不应单独安装.

注意:我不仅需要分离资源,还需要分离活动,因此APK Expansion Files不需要解决方案,因为不提供此类功能.

android android-install-apk

7
推荐指数
1
解决办法
3574
查看次数

antisamy解析器强制关闭标签

我使用Antisamy来验证HTML.我的政策允许iframe,例如youtube视频.问题是 - 如果标签为空(如下所示):

<iframe src="//www.youtube.com/embed/uswzriFIf_k?feature=player_detailpage" allowfullscreen></iframe>
Run Code Online (Sandbox Code Playgroud)

比清洁后,它将是这样的:

<iframe src="//www.youtube.com/embed/uswzriFIf_k?feature=player_detailpage" allowfullscreen/>
Run Code Online (Sandbox Code Playgroud)

但它应该有正常的结束标记.

这打破了页面上的所有内容.我已经将我的指令设置为使用大部分HTML但不使用XML:

<directives>
    <directive name="omitXmlDeclaration" value="true"/>
    <directive name="omitDoctypeDeclaration" value="true"/>
    <directive name="maxInputSize" value="200000"/>
    <directive name="nofollowAnchors" value="true" />
    <directive name="validateParamAsEmbed" value="true" />
    <directive name="useXHTML" value="false"/>

    <directive name="embedStyleSheets" value="false"/> 
    <directive name="connectionTimeout" value="5000"/>
    <directive name="maxStyleSheetImports" value="3"/>
    <directive name="formatOutput" value="false"/>
</directives>
Run Code Online (Sandbox Code Playgroud)

但这没有用.

UPD:在解析器之间切换和使用指令仍然没有给出任何结果.

UPD2:这是我的配置的一部分,负责处理iframe标签:

    <tag name="iframe" action="validate">
        <attribute name="src">
            <regexp-list>
                <regexp name="youtube"/>
                <regexp name="slideshare"/>
            </regexp-list>
        </attribute>
        <attribute name="allowfullscreen">
             <regexp-list>
                 <regexp name="anything"/>
             </regexp-list>
        </attribute>
        <attribute name="scrolling">
            <regexp-list>
                <regexp name="anything"/>
            </regexp-list>
        </attribute>
        <attribute name="marginwidth">
            <regexp-list> …
Run Code Online (Sandbox Code Playgroud)

java security html-parsing owasp antisamy

6
推荐指数
1
解决办法
1304
查看次数

firefox插件更改响应代码

我有一个扩展,检查http-on-examine-response侦听器中的响应.在听众可以通过改变头的HTTPChannel,并通过nsITraceableChannel我们可以改变响应内容.

但是如何在http-on-examine-response监听器中更改响应代码(例如从407到200)?

一些代码:

const { Ci, Cu, Cc, Cr } = require('chrome');

Cu.import('resource://gre/modules/Services.jsm');

var observer = {
  observe: function(aSubject, aTopic, aData) {
    if (aTopic == 'http-on-examine-response') {
        console.log('we are in observer http-on-examine-response');
        var httpChannel = aSubject.QueryInterface(Ci.nsIHttpChannel);
        if(httpChannel.responseStatus == 407){
            httpChannel.responseStatus = 200; // <-- this is not working
        }
    }

  }
};

Services.obs.addObserver(observer, 'http-on-examine-response', false);


exports.onUnload = function (aData, aReason) {
  Services.obs.removeObserver(observer, 'http-on-examine-response');
};
Run Code Online (Sandbox Code Playgroud)

firefox firefox-addon firefox-addon-sdk

6
推荐指数
0
解决办法
404
查看次数

rxjava 行为主题删除/清除值

我有一个应用程序,它BehaviorSubject用作某种价值的内存存储。如果用户已登录或在用户登录期间,此值将根据 REST API 请求的结果在应用程序启动时设置。但是当用户注销时, BehaviorSubject 保持旧值。有什么方法可以根据需要清除BehaviorSubject并强制其hasValue()为假?

reactive-programming rx-java

5
推荐指数
1
解决办法
4769
查看次数

CSVPrinter 仅删除标题中的引号

当值被引用时,我需要在模式下使用 Apache 公共资源中的 CSVPrinter,但标头不是。看起来报价模式是唯一的选项,影响标题和值。这个可以独立完成吗?

CSVFormat format = CSVFormat.DEFAULT.withHeader(new String(){"a", "b"})
                .withQuoteMode(QuoteMode.ALL);
CSVPrinter printer = new CSVPrinter(new FileWriter(new File("out.csv")), format);
printer.printRecord("a val", "b val");
printer.printRecord("1", "2");
printer.flush();
printer.close();
Run Code Online (Sandbox Code Playgroud)

给出:

"a", "b"
"a val", "b val"
"1", "2"
Run Code Online (Sandbox Code Playgroud)

但要求是这样的:

a,b
"a val", "b val"
"1", "2"
Run Code Online (Sandbox Code Playgroud)

java csv apache-commons

3
推荐指数
1
解决办法
1525
查看次数

extjs 布局在 vbox 内滚动

我在向网格添加滚动条时遇到问题,即在 vbox 容器内。我不能直接指定高度,因为我不知道。在那个 vbox 容器中也是具有未定义高度的“另一个内容”,所以我既不能使用“高度”,也不能使用“flex”。我需要让网格填充页面中的所有剩余空间,如果行数超出了它的容量 - 我需要向该网格添加滚动条。这是代码中最重要的部分:

{
layout: {
    type: 'vbox',
    align: 'stretch'
}, 
items:[
    {
        title: 'center'
    },{
        html: 'another content'
    },{
        xtype: 'grid',
        autoScroll: true, // <-- this is not working
        columns: [
            { text: 'User', dataIndex: 'userId' }
        ],
        store: new Ext.data.Store({
            model: 'Ext.data.Record',
            fields: [
                { name: 'userId', type: 'string' }
            ],
            data: ( function(){
                var res = []
                for(var i=0; i<1000; i++){
                    res.push({ userId: 'User'+i});
                }
                return res;
            })()
        })

    }
]
}
Run Code Online (Sandbox Code Playgroud)

我尝试了很多变体,但都没有成功。我还为大多数逻辑解决方案准备了一些小提琴(但无论如何滚动都不起作用): …

javascript layout extjs sencha-touch extjs5

2
推荐指数
1
解决办法
5528
查看次数

谷歌应用程序脚本获取脚本请求URL

在谷歌脚本中我需要获取此脚本网址.它有网址喜欢"https://script.google.com/macros/s/somecharshere/exec"

我需要获取此URL(并发送响应).

但我发现没有办法做到这一点.我只能通过e.parameter.*获取查询参数,但不是完整的请求网址.有没有办法做到这一点?

google-apps-script

1
推荐指数
1
解决办法
1760
查看次数

将UTF8字符串转换为UCS-2并替换java中的无效字符

我对 UTF8 感到困惑:

\n
\n

“RedR\xc3\xb6ses”

\n
\n

我需要将其转换为有效的 UCS-2(或没有 BOM 的固定大小 UTF-16BE,它们是相同的东西)编码,因此输出将是:\n“Red R\xc3\xb6ses”作为“”输出UCS-2 的射程。

\n

我尝试过的:

\n
 @Test\npublic void testEncodeProblem() throws CharacterCodingException {\n    String in = "Red\\uD83C\\uDF39\\uD83C\\uDF39R\xc3\xb6ses";\n    ByteBuffer input = ByteBuffer.wrap(in.getBytes());\n\n    CharsetDecoder utf8Decoder = StandardCharsets.UTF_16BE.newDecoder();\n    utf8Decoder.onMalformedInput(CodingErrorAction.REPLACE);\n    utf8Decoder.onUnmappableCharacter(CodingErrorAction.REPLACE);\n    utf8Decoder.replaceWith(" ");\n\n    CharBuffer decoded = utf8Decoder.decode(input);\n\n    System.out.println(decoded.toString()); //  \xe5\x89\xa5\xe6\x93\xb0\xe9\xbe\x8c\xeb\xa7\xb0\xe9\xbe\x8c\xeb\xa5\x92\xec\x8e\xb6\xe7\x8d\xa5 \n}\n
Run Code Online (Sandbox Code Playgroud)\n

没有。

\n
    @Test\npublic void testEncodeProblem() {\n    String in = "Red\\uD83C\\uDF39\\uD83C\\uDF39R\xc3\xb6ses";\n    byte[] bytes = in.getBytes(StandardCharsets.UTF_16BE);\n    String res = new String(bytes);\n    System.out.println(res); //  Red\xef\xbf\xbd<\xef\xbf\xbd9\xef\xbf\xbd<\xef\xbf\xbd9R\xc3\xb6ses\n}\n
Run Code Online (Sandbox Code Playgroud)\n

没有。

\n

请注意,“\xc3\xb6”是有效的 UCS-2 符号。

\n

有什么想法/图书馆吗?

\n

java unicode encoding utf-8 utf-16

0
推荐指数
1
解决办法
1850
查看次数