我正在尝试使用Grails中的Criteria加载不同的父级.查询如下
查询:
def criteria = Parent.createCriteria();
results = criteria.list(max:params.max, offset:params.offset){
projections{ groupProperty('id') }
children{
books{
like('title',"%book")
}
}
order("id","asc")
}
Run Code Online (Sandbox Code Playgroud)
域类
class Parent {
String name
static hasMany = [children:Child]
static constraints = {
}
}
class Child {
String name
Parent parent
static belongsTo = [parent:Parent]
static hasMany = [books:Book]
static constraints = {
}
}
class Book {
String title
Child child
static belongsTo = [child:Child]
static constraints = {
}
}
Run Code Online (Sandbox Code Playgroud)
问题:我无法获得明显的父行.
其他采用的方法及其结果:我不知道为什么groupProperty不工作.我尝试过 …
我有一组12个图像在布局中显示.这个数字是半任意选择的,但是对于纵向模式可以归结为3个横向和4个垂直,而对于横向模式则相反.
第一个实现是使用gridview.问题是高度不能强制适合屏幕.对于一种解决方法,我可以(尝试)缩放课程图像,但几乎不可能计算出网格视图可用的空间:总屏幕尺寸是已知的,但你必须"猜测"通知栏的大小并且没有'似乎是一种优雅的溶剂.测量的大小实际上并不值得信任:我没有在方向更改(速度)上完全重新启动,但是屏幕的构建方式不能在现场获得完整的空间.最后得出的结论是,我不想计算图像的大小,然后相应地对它们进行缩放:我认为最好说出视图应该如何适应屏幕,对吧?
所以接下来的尝试就是使用TableLayout.使用"ShrinkColumns ="*"图像很合适,所以图像的大小现在是我们想要它们的大小.但是我们可能在高度上的'额外'空间现在在桌面之间均匀分配.这是可以预期的,但很难看
当前的代码似乎无关紧要,因为它不起作用,但最终看起来像这样:我已经删除了所有填充和其他看起来不相关的东西.(对于肖像:)
<TableLayout
android:shrinkColumns="*">
<TableRow>
<ImageView/>
<ImageView/>
<ImageView/>
</TableRow>
… (repeat 3 tablerows)
</TableLayout>
Run Code Online (Sandbox Code Playgroud)
为了"缩放"过大的图像,TableLayout具有"shrinkcolumns ="*""属性.
我们怎样才能让三个ImageView在TableRow的中心对齐而不是在宽度上均匀分布?对于垂直列也是如此,我们如何将所有内容保持在一起而不是在屏幕的高度上展开?基本上,"多余"空间应该作为填充/边距到达边,现在它介于图像之间.
示例:左侧屏幕截图显示左/右距离太多,右侧有太多顶部/底部

我正在尝试创建一个简单的目录(文档只有4页长).我遇到的问题是,当我的鼠标确实变成一只手时,当我点击它时没有任何反应.是的,目标在另一页上.
创建目录行:
Chunk chunk = new Chunk("Contact information");
chunk.setLocalGoto("Contact information");
document.add(new Paragraph(chunk));
Run Code Online (Sandbox Code Playgroud)
其中一个目标:
Anchor anchor = new Anchor("Contact information", font1);
anchor.setName("Contact information");
Chapter chapter = new Chapter(new Paragraph(anchor), 1);
chapter.setNumberDepth(0);
document.add(chapter);
Run Code Online (Sandbox Code Playgroud)
在Goto String与比赛Anchor name,所以我不明白我在做什么错.
我在 C# 和 PostgreSQL 中出现错误“Too Many Clients Already”,我做错了什么吗?
这是我的主要代码
public class NationalService
{
private NpgsqlConnection conn;
protected string query;
public NationalService()
{
this.conn = ConnectionService.GetConnection();
}
public string GetNamaWilayah(string kodePropinsi, string kodeKabupaten)
{
this.query = "select namakabupaten from dim_gab_wilayah where kodepropinsi='" + kodePropinsi + "' and kodekabupaten='" + kodeKabupaten + "' group by namakabupaten";
string namaKabupaten;
using (NpgsqlCommand command = new NpgsqlCommand(this.query, this.conn))
{
using (NpgsqlDataReader dr = command.ExecuteReader())
{
while (dr.Read())
{
namaKabupaten = dr["namakabupaten"].ToString();
return namaKabupaten;
}
} …Run Code Online (Sandbox Code Playgroud) 只是好奇,哪个代码更有效:
if (myClass.getSomeValue() != myValue) myClass.setSomeValue(myValue);
Run Code Online (Sandbox Code Playgroud)
或者干脆
myClass.setSomeValue(myValue);
Run Code Online (Sandbox Code Playgroud)
,在哪里getSomeValue()和setSomeValue(...)是简单的getter-setter对?很明显,如果.equals()使用的话,第二个会更快,所以我们只使用!=.
有没有办法(使用XPath和PHP)执行以下操作(没有外部XSLT文件)?
我在这里收到了一个XSLT答案,但我正在寻找不需要外部文件的XPATH查询.
目前,我通过以下方式将有问题的HTML加载到SimpleXmlElement中:
$doc = @DOMDocument::loadHTML($xml);
$data = simplexml_import_dom($doc);
Run Code Online (Sandbox Code Playgroud)
现在我需要帮助:
$data = $data->xpath('??????');
Run Code Online (Sandbox Code Playgroud)
一直在使用这个几天无济于事.我非常感谢你的帮助.
编辑:我并不特别在意段落内的内容,因为我可以使用strip_tags来消除我不想要的内容.我需要做的就是将段落与其他来源隔离开来.我想更具体,更准确的要求是:
仅返回未包含在表中且仅在第一个h1标记之前的段落(及其html内容)
编辑2:
我想我已经完成了大部分工作:
$query = $xpath->query('//p[not(ancestor::table) and not(preceding::h2)]');
唯一的问题是内部HTML的丢失.
我正在开发一个Django站点,并且一直在努力找出处理异常处理的最佳方法.我一直在做
try:
Some code
except:
log error in my own words, i.e 'Some code' failed to execute
Some other code
Run Code Online (Sandbox Code Playgroud)
这可以捕获所有异常,从而确保我的网站不会传递500个错误等.但是,由于我的知识有限,我正在失去实际的异常,这使得调试变得非常痛苦.如何打印出现的错误?目前我注释掉了try:catch:并查看错误并修复它.肯定有更好的办法!
提前致谢
丰富
这是这样的事情:
for(;;)
{
statements;
}
Run Code Online (Sandbox Code Playgroud)
或者是这样的:
for(initialisation;condition;updation)
{
}
Run Code Online (Sandbox Code Playgroud)
我正在寻找各种来源的答案.
java ×3
performance ×2
android ×1
architecture ×1
c ×1
c# ×1
c++ ×1
grails ×1
grails-orm ×1
gridview ×1
hardware ×1
hibernate ×1
html-parsing ×1
itext ×1
optimization ×1
php ×1
postgresql ×1
python ×1
regex ×1
tablelayout ×1
xpath ×1