我正在尝试使用以下代码从MySQL
表中提取Experience对象列表.每个体验都有一个from datetime
列和一个datetime
列,我只想拉出今天日期落在from和to之间的行.
我正在使用JPA 2.0运行Hibernate.
Date currentDate = new Date();
CriteriaBuilder builder = entityManager.getCriteriaBuilder();
CriteriaQuery<Experience> query = builder.createQuery(Experience.class);
Root<Experience> root = query.from(Experience.class);
builder.between(currentDate, root.get("from"), root.get("to"));
return entityManager.createQuery(query).getResultList();
Run Code Online (Sandbox Code Playgroud)
我的问题是,builder.between()
显然不允许我传递Date对象.
我的问题有更好的解决方案吗?
这是我用来构建LINQ语句原型的SQL.代码中的GUID是List<GUID>
.我尝试了3个小时,但是没有得到它.可以在睡梦中写一些LINQ的人可以帮助我.
SELECT DISTINCT [id]
,[emailAddress]
,[name]
,[emailRunNumber]
FROM [emailAddress]
join promotionsJoin
on promotionsJoin.EmailAddressId = emailAddress.id
where promotionsJoin.promotionId in ('09464b57-f3d7-41ec-b0b1-cbc5999824bd',
'8bc855b2-2f01-4083-b43a-dab7b7a81ac8') AND emailRunNumber is NULL
Run Code Online (Sandbox Code Playgroud) 我目前正在重建我的网站的数据库.由于我现在的模式不是最好的模式之一,我认为听取您的一些建议会很有用.
首先,我的网站实际上包含小部件.对于每个小部件,我需要一个表settings
(其中小部件的每个实例都有其用户定义的设置),一个表common
(用于同一小部件的实例之间的共享项)和userdata
(用户在小部件实例中保存的数据).
到目前为止,我有以下架构,由2个数据库组成:
user_id
,widget_id
和unique_id
).widget_id
),我有三个表:[widget_id]_settings
,[widget_id]_common
和[widget_id]_userdata
.在每个表中,每行都保存unique_id
用户窗口小部件的行.实际上,这是存储在窗口小部件中的所有用户数据.举一个我的数据库如何工作的简短例子:
第一个数据库
users
我的表中user_id = 1
widgets
我的表中widget_id = 1
users_widgets
我的表中user_id = 1, widget_id = 1, unique_id = 1
第二数据库:
1_settings
我有unique_id = 1, ...
,其中...代表用户的小部件设置1_common
我有几行代表同一小部件的实例之间的共享数据(所以,这里没有用户特定的数据)1_userdata
我有unique_id = 1, ...
,其中...代表用户的小部件数据.这里一个重要的通知是这个表可能包含几行相同的行unique_id
(例如,对于任务小部件,用户可以为小部件实例创建多个任务)希望你能粗略理解我的数据库架构.
现在,我想开发一个"更清洁"的模式,因此没有必要在我的应用程序中拥有2个数据库并每次从一个数据库切换到另一个数据库.如果我找到一种不在第二个数据库(1_settings,2_settings,...,n_settings)中动态生成表格的方法,那也会很棒.
我将非常感谢任何建议任何更好的方法来实现这一目标.非常感谢你提前!
编辑: 重构我的数据库时,我的脑海中是否有像MongoDB或CouchDB这样的数据库?我的意思是,对于第二个数据库,如果我没有固定的模式会更好.此外,传统的SQL和NoSQL如何在同一网站上相处?
在我们的程序安装过程中,我们运行此方法来加密app.config的各个部分:
// Get the application configuration file.
Configuration config =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
// Define the Rsa provider name.
const string provider = "RsaProtectedConfigurationProvider";
// Get the section to protect.
ConfigurationSection connStrings = config.ConnectionStrings;
if (connStrings != null)
{
if (!connStrings.SectionInformation.IsProtected)
{
if (!connStrings.ElementInformation.IsLocked)
{
// Protect the section.
connStrings.SectionInformation.ProtectSection(provider);
connStrings.SectionInformation.ForceSave = true;
config.Save(ConfigurationSaveMode.Full);
}
}
}
Run Code Online (Sandbox Code Playgroud)
到目前为止工作正常.但是如果我运行这个程序,我们会遇到几个机器出现以下错误"无法使用提供程序'RsaProtectedConfigurationProvider解密'.来自提供程序的错误消息:无法打开RSA密钥容器 ".
当然,我搜索并找到了这个帮助,但这不起作用.有任何想法吗?
谁能告诉我是否有办法向 Makefile.am 插入条件块,以便将其进一步传递给由 autotools 创建的 Makfile?
下面是一个例子:
ifeq "$(SOMEVAR)" ""
SOMEVAR="default_value"
endif
Run Code Online (Sandbox Code Playgroud)
这似乎是做有条件的事情的常见 Makefile 方式。Automake 切断 endif 行并最终失败并显示如下消息:
Makefile:390: *缺少‘endif’。停止。
有什么想法吗?
所以,我的目标是在另一个线程中启动一个函数.此外,我需要从新线程访问其他vcl组件.到目前为止,这是我的代码:
procedure TForm1.StartButtonClick(Sender: TObject);
var
thread1: integer;
id1: longword;
begin
thread1 := beginthread(nil,0,Addr(Tform1.fetchingdata),nil,0,id1);
closehandle(thread1);
end;
procedure TForm1.FetchingData;
var
...
begin
Idhttp1.IOHandler := IdSSLIOHandlerSocketOpenSSL1; //<- error
idhttp1.Request.ContentType := 'application/x-www-form-urlencoded';
Run Code Online (Sandbox Code Playgroud)
我的程序挂起,我收到错误:00154E53模块my.exe中的异常EAccessViolation.模块"my.exe"中地址00554E53的访问冲突.读取地址00000398.
提前致谢.
我有一个数组,我从数据库ResultSet创建.我正在尝试序列化它,以便我可以通过套接字流发送它.目前我收到一个错误,告诉我该数组不是Serializable.我的代码在下面,第一部分是为数组创建对象的类:
class ProteinData
{
private int ProteinKey;
public ProteinData(Integer ProteinKey)
{
this.ProteinKey = ProteinKey;
}
public Integer getProteinKey() {
return this.ProteinKey;
}
public void setProteinKey(Integer ProteinKey) {
this.ProteinKey = ProteinKey;
}
}
Run Code Online (Sandbox Code Playgroud)
填充数组的代码:
public List<ProteinData> readJavaObject(String query, Connection con) throws Exception
{
PreparedStatement stmt = con.prepareStatement(query);
query_results = stmt.executeQuery();
while (query_results.next())
{
ProteinData pro = new ProteinData();
pro.setProteinKey(query_results.getInt("ProteinKey"));
tableData.add(pro);
}
query_results.close();
stmt.close();
return tableData;
}
Run Code Online (Sandbox Code Playgroud)
调用它的代码是:
List dataList = (List) this.readJavaObject(query, con);
ObjectOutputStream output_stream = new ObjectOutputStream(socket.getOutputStream());
output_stream.writeObject(dataList);
Run Code Online (Sandbox Code Playgroud)
接收到的代码是:
List …
Run Code Online (Sandbox Code Playgroud) 有没有办法在MySQL中指定Unicode字符文字?
我想用Ascii字符替换Unicode字符,如下所示:
Update MyTbl Set MyFld = Replace(MyFld, "?", "y")
Run Code Online (Sandbox Code Playgroud)
但是我使用的是大多数字体都没有的更加模糊的字符,所以我希望能够使用Unicode字符文字,比如
Update MyTbl Set MyFld = Replace(MyFld, "\u1e8f", "y")
Run Code Online (Sandbox Code Playgroud)
这个SQL语句是从PHP脚本调用的 - 第一个表单不仅不可读,而且实际上不起作用!
如何为每个记录启用超链接JTable
?
我想要做的是,用户可以点击超链接,然后显示他们可以编辑/更新的信息.
或者,如何启用表格数据的编辑?
另一个问题是我目前正在使用以下方式显示不同的屏幕.但这不是一种优雅的方式,我知道我们应该使用cardlayout,但究竟如何去做呢?
mainPanel.setVisible(false);
createBlogEntryPanel.setVisible(true);
setComponent(createBlogEntryPanel);
Run Code Online (Sandbox Code Playgroud) ViM中的超级星(*)键将搜索光标下的单词并跳转到下一个匹配项.用户可以使用n
密钥跳转到下一个匹配项.如果hlsearch
启用,它还会突出显示匹配项.
我希望能够按*并获得突出显示的匹配,并能够使用n键导航匹配.但是,我不希望ViM在按下*时跳转到下一个匹配,它应该保留在当前单词上.有没有办法做到这一点?