我想知道在Java中是否有办法做这样的事情:
if(word in stringArray) {
...
}
Run Code Online (Sandbox Code Playgroud)
我知道我可以为此创建一个函数,但我只是想知道Java是否已经有了这个功能.
谢谢!
我可以懒惰加载一对多和多对一的关联,但我不能与多对多关联.
我们有一个城市,我们有商人有地址.商家可以拥有多个地址,多个商家可以拥有相同的地址.
当我们用get获取商家时,
Merchant merchant = (Merchant) hib_session.get(Merchant.class, id);
System.out.println(merchant.getName());
Run Code Online (Sandbox Code Playgroud)
没关系,在我们遍历它们之前,地址不会加载.
但是当我们加载商家列表时,
City city = (City) hib_session.get(City.class, city_name);
for(Merchant merchant : city.getMerchants()) {
System.out.println(merchant.getName());
}
Run Code Online (Sandbox Code Playgroud)
即使我们没有获取地址,hibernate也会自动加载它们.
映射:
<class name="Merchant" table="Merchants" lazy="true">
<id name="id"
type="long"
column="id">
<generator class="native"></generator>
</id>
<set name="addresses" table="AdressesMerchant" lazy="true">
<key column="merchant_id"></key>
<many-to-many class="Adresses" column="address_id"/>
</set>
</class>
<class name="Address" table="Adresses" lazy="true">
<id name="id"
type="long"
column="id">
<generator class="native"></generator>
</id>
<set name="merchants" table="AdressesMerchant" lazy="true">
<key column="adress_id"/>
<many-to-many column="merchant_id" class="Merchant"/>
</set>
</class>
Run Code Online (Sandbox Code Playgroud)
有任何想法吗 ?
请关注我:
我只是想在当前日期添加10年,然后从中减去过期日期以返回年数:
public int getMaxYears() {
int max = 0;
Calendar ten_year_later = Calendar.getInstance();
ten_year_later.setTime(new Date());
ten_year_later.add(Calendar.YEAR, 10);
Calendar expiration = Calendar.getInstance();
expiration.setTime(expiration_date);
max = (int) (ten_year_later.getTimeInMillis() - expiration.getTimeInMillis())/(365 * 24 * 60 * 60 * 1000);
return max;
}
Run Code Online (Sandbox Code Playgroud)
当我调试它时,日历始终保持在当前年份.
任何人 ?
这是我的查询,它们不起作用,但我想做这样的事情:
SELECT a_field FROM a_table
WHERE
...
AND
CASE
WHEN a_value_from_another_query IS NULL THEN a_second_field IS NULL
ELSE a_second_field = a_value_from_another_query
END
Run Code Online (Sandbox Code Playgroud)
要么
SELECT a_field FROM a_table
WHERE
...
AND
CASE a_value_from_another_query
WHEN NULL THEN a_second_field IS NULL
ELSE a_second_field = a_value_from_another_query
END
Run Code Online (Sandbox Code Playgroud)
要么
SELECT a_field FROM a_table
WHERE
...
AND
CASE NVL(a_value_from_another_query, 'x')
WHEN 'x' THEN a_second_field IS NULL
ELSE a_second_field = a_value_from_another_query
END
Run Code Online (Sandbox Code Playgroud)
什么时候a_value_from_another_query IS NULL,我想添加a_second_field IS NULL到我的WHERE子句,何时a_value_from_another_query IS NOT NULL,我想添加a_second_field …
我有这个菜单:
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.js"></script>
<script>
$(function() {
$("#menu").find("li").each(function() {
if ($(this).find("ul").length > 0) {
$(this).mouseenter(function() {
$(this).find("ul").stop(true, true).slideDown();
});
$(this).mouseleave(function() {
$(this).find("ul").stop(true, true).slideUp();
});
}
});
});
</script>
<style>
#menu {
display:block;
margin:120px auto 20px;
border:1px solid #222;
position:relative;
background-color:#6a6a6a;
font:16px Tahoma, Sans-serif;
}
#menu ul {
padding:0;
margin:0;
}
#menu li {
position:relative;
float:left;
list-style-type:none;
}
#menu ul:after {
content:".";
display:block;
height:0;
clear:both;
visibility:hidden;
}
#menu li a {
display:block;
padding:10px 20px;
border-left:1px solid #999;
border-right:1px solid …Run Code Online (Sandbox Code Playgroud) 我正在制作一个Shell脚本,我想知道执行脚本时是否可以直接写到命令行?
范例:
user@localhost:/home/user$./script.sh
... output
... another output
... another output
... last output
user@localhost:/home/user$I want to write here on the command line
Run Code Online (Sandbox Code Playgroud)
我不想“回显”某些文本,我想直接在提示符下写。
谢谢!
我从HashMap获取HashSet,我不希望我对HashSet的修改反映在HashMap值上.
做这样的事情的最佳方式是什么:
HashSet<Object> hashset = new HashSet((Collection<Object>) hashmap.values());
//Something like ...
hashset.detach();
//Then i can modify the HashSet without modifying the HashMap values
Run Code Online (Sandbox Code Playgroud)
编辑: 我必须修改HashSet中的一个元素,但我不想在HashMap中修改这个相同的元素.
谢谢!!!
java ×4
calendar ×1
collections ×1
command-line ×1
css ×1
function ×1
hibernate ×1
html ×1
jquery ×1
lazy-loading ×1
linux ×1
many-to-many ×1
map ×1
menu ×1
oracle ×1
oracle11g ×1
shell ×1
sql ×1