我正在使用JPA2和Hibernate实现.
我有这样的简单映射:
@Entity
class Topic {
@Id
@GeneratedValue(strategy = IDENTITY)
int id;
@OneToOne(cascade = ALL)
@JoinColumn(name = "id_poll")
private Poll poll;
}
@Entity
class Poll {
@Id
@GeneratedValue(strategy = IDENTITY)
int id;
}
Run Code Online (Sandbox Code Playgroud)
现在,当我删除一个也在Topic中的Poll对象时,我收到一个错误.
java.sql.SQLException:完整性约束违规FKCC42D924982D3F4B表:语句中的TOPICS [从民意调查中删除id =?]
我理解这是因为如果Poll记录在另一个表中有引用,我就无法删除它.我怎么解决这个问题?我是否必须在主题表中手动设置poll = null或者是否有更好的解决方案?
在向iTunes Connect for AppStore分发提交iPhone应用程序后,他们要求提供512x512像素的图像.以下是提交它的地方旁边的内容:
"将在App Store上使用的大型应用程序图标.它必须至少为72 DPI,最小为512x512像素(不能放大).它必须是没有圆角的平面艺术品."
那么他们是否像其他地方一样绕过角落?iOS人机界面指南未标明:"此版本的应用程序图标没有添加视觉效果"
然而,我在iTunes应用商店中看到的所有图像都是圆形的.iTunes的网页版也显示圆形图标,实际上是175,175平方,带有圆角的图像蒙版:http://a1.phobos.apple.com/us/r1000/050/Purple/49/68/e3 /mzi.wijnmlbw.175x175-75.jpg和http://ax.phobos.apple.com.edgesuite.net/htmlResources/2CBF/images/mask175.png.
我正在研究AES算法,我有这个例外,我无法解决.
javax.crypto.BadPaddingException: Given final block not properly padded
at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
at com.sun.crypto.provider.AESCipher.engineDoFinal(DashoA13*..)
at javax.crypto.Cipher.doFinal(DashoA13*..)
Run Code Online (Sandbox Code Playgroud)
异常发生在解密部分.我在与解密算法不同的地方初始化密钥
KeyGenerator kgen = KeyGenerator.getInstance("AES");//key generation for AES
kgen.init(128); // 192 and 256 bits may not be available
Run Code Online (Sandbox Code Playgroud)
然后我用我从文件中读取的密文传递给下面的方法
public String decrypt(String message, SecretKey skey) {
byte[] raw = skey.getEncoded();
SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
// Instantiate the cipher
Cipher cipher;
byte[] original = null;
try {
cipher = Cipher.getInstance("AES");
cipher.init(Cipher.DECRYPT_MODE, skeySpec);
System.out.println("Original string: "
+ message);
original = cipher.doFinal(message.trim().getBytes()); //here where I …Run Code Online (Sandbox Code Playgroud) 我有一个问题,我需要"模拟"麦克风输出.
数据将通过网络传输,解码为PCM,基本上需要写入麦克风 - 然后其他程序可以读取/记录/无论如何.
我一直在阅读alsa,但信息非常稀少.文件插件看起来很有前途 - 我正在考虑将命名管道作为"infile",然后我可以从我的应用程序传递数据.然而,我无法让它工作(vlc/audacity只是段错误).
pcm.testing {
type file
slave {
pcm {
type hw
card 0
device 0
}
}
infile "/dev/urandom"
format "raw"
}
Run Code Online (Sandbox Code Playgroud)
有没有更好的方法来做到这一点?有关alsa插件的任何建议(特别是文件插件)?
我有一些问题.给出以下C++代码片段:
#include <boost/progress.hpp>
#include <vector>
#include <algorithm>
#include <numeric>
#include <iostream>
struct incrementor
{
incrementor() : curr_() {}
unsigned int operator()()
{ return curr_++; }
private:
unsigned int curr_;
};
template<class Vec>
char const* value_found(Vec const& v, typename Vec::const_iterator i)
{
return i==v.end() ? "no" : "yes";
}
template<class Vec>
typename Vec::const_iterator find1(Vec const& v, typename Vec::value_type val)
{
return find(v.begin(), v.end(), val);
}
template<class Vec>
typename Vec::const_iterator find2(Vec const& v, typename Vec::value_type val)
{
for(typename Vec::const_iterator i=v.begin(), end=v.end(); i<end; …Run Code Online (Sandbox Code Playgroud) 到目前为止,我已经编程了大约11年,并使用了许多不同的编程语言,从Python到C.
然而,我感到惭愧的是,我仍然缺少很多基础知识,而这些基础知识都建立在以下基础之上:
堆栈和堆的可执行文件是如何构建的以及它们如何工作
CPU如何工作?
什么是时钟周期
什么是数据总线
我的主板上的北桥和南桥如何工作
低级二进制逻辑/计算
这些只是一些例子,我正在寻找的是对此的一些很好的介绍,因为我觉得这只是成为一名优秀程序员所需要的知识.
我很清楚这些模式中的每一个是如何工作的,并且知道它们之间的一些细微差别,但它们真的是彼此之间的差异吗?
在我看来,Presenter,Presentation Model,ViewModel和Controller本质上是相同的概念.
为什么我不能将所有这些概念归类为控制器?我觉得它可能会大大简化整个想法.
任何人都可以清楚地描述他们的差异吗?
我想澄清一点,我确实理解模式是如何工作的,并且已经在一种技术或另一种技术中实现了大部分模式.我真正想要的是某人对这些模式之一的体验,以及为什么他们不会将他们的ViewModel视为一个控制器.
我会给出一些声望点,但我正在寻找一个非常好的答案.
model-view-controller mvp design-patterns presentation-model mvvm
这是我的HTML.下表位于容器div内,其固定宽度为670px.现在我不知道如何继续使这个表捕获容器的整个宽度.
<table class="table_fields">
<tr class="table_fields_top">
<td><?php _e('Published','news'); ?></td>
<td><?php _e('Story','news'); ?></td>
<td><?php _e('Views','news'); ?></td>
<td><?php _e('Comments','news'); ?></td>
<td><?php _e('Rating','news'); ?></td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
这是我的CSS:
.table_fields {
display: block;
background: #fff;
border: 1px solid #dce1e9;
border-bottom: 0;
border-spacing: 0;
}
.table_fields .table_fields_top {background: #f1f3f6;}
.table_fields .table_fields_top td{
font-size: 10px;
text-transform: uppercase;
}
.table_fields td {
text-align: center;
border-bottom: 1px solid #dce1e9;
border-right: 1px solid #dce1e9;
font-size: 11px;
line-height: 16px;
color: #666;
white-space:nowrap;
}
Run Code Online (Sandbox Code Playgroud)
我试着设置宽度:100%; 但它返回空的空间,但TD不平衡.我不知道如何使TD始终充满100%的空间.我尝试设置宽度:每个TD为20%,因为它们是5 tds以获得100%宽度.但这没效果.有人可以告诉我如何使细胞适合表格的FUll宽度100%(假设每个TD有一个固定的宽度百分比,如20%)请.
我写了这两个简单的加密和解密字符串的类:
Encode.php
class Encode {
protected funcion do_encode($string) { .. }
}
Decode.php
class Decode {
protected funcion do_decode($string) { .. }
}
我会做的是:
Encrypt.php
class Encrypt extends Encode, Decode {
protected $stuff_for_parents;
function __construct($configs) {
$this->stuff_for_parents = $configs['SomeConf'];
}
public function encode($string) { $this->do_encode($string); }
public function decode($string) { $this->do_decode($string); }
}
但是我们不能包含多个类,所以:失败.
现在我的问题是:
$encrypt->encode($str); $encrypt->decode($str);我正在构建一个独立程序,因此程序没有外部文件可供访问.什么是最好的方式来回忆窗口的大小,窗口内某个元素的位置是在最后一次关闭之前?
assembly ×2
alsa ×1
app-store ×1
audio ×1
c# ×1
c++ ×1
cascade ×1
cryptography ×1
css ×1
encryption ×1
exception ×1
find ×1
hardware ×1
hibernate ×1
html ×1
html-table ×1
image ×1
iphone ×1
java ×1
jpa-2.0 ×1
linux ×1
low-level ×1
microphone ×1
mvp ×1
mvvm ×1
one-to-one ×1
performance ×1
php ×1
preferences ×1
settings ×1
stl ×1
virtual ×1