通过Javascript获取链接的价值(Getting the value of a link by Javascript)
情况就是这样:我有一个只给出1或0的页面链接; http://www.mybilet.com/connectors/functionAjax.php?islem=getBosDoluKoltuk&serverId=228&showtimeId=46666
佩奇不是我的。 所以我想根据这个值在另一个页面中建立一个报警系统。 即如果值为1,则页面播放音乐。 如何获取此值并在Javascript中编写if语句。
Here is the situation: I have a link of a page that gives only 1 or 0; http://www.mybilet.com/connectors/functionAjax.php?islem=getBosDoluKoltuk&serverId=228&showtimeId=46666
Page is not mine. So I want to build an alarm system in another page according to this value. i.e. if the value is 1, the page plays a music. How can I get this value and write the if statement in Javascript.
原文:https://stackoverflow.com/questions/1943188
最满意答案
即使Hibernate是最常用的JPA实现,我也会坚持使用规范API(JPA)。
所以EntityManager
而不是Session
。通常,您想编写自己的查询,因为查询具有最低程度的复杂性。
但特定的JPA / Hibernate方法不允许执行这种查询。
这些方法只处理简单的情况。因此,作为一般规则,您应该在每次可能时都支持特定的JPA / Hibernate方法而不是自定义查询创建。
通常是避免使用JPQL编写boiler plate代码的捷径。
例如,如果你想从它的ID中检索一个实体,那么你没有任何价值来写一个如此简单的查询。
你将不得不编写锅炉板代码(创建查询,设置参数查询,执行查询)。
使用EntityManager.find(Class<T>, Object)
是一种更简单也更清晰的方法,因为您不需要进一步了解行为。请注意,Spring Data JPA进一步提供了更多方法来处理其他经典查询。
SimpleJpaRepository类就是一个很好的例子。最后,请注意,在某些情况下,特定的JPA / Hibernate方法来操纵实体并不是一种选择。
与实体或EntityManager
状态相关的操作只能用这些方法(persist()
,flush()
或refresh()
,clear()
...)执行。Even if Hibernate is the most commonly JPA implementation used, I would stick rather on the specification API (JPA).
SoEntityManager
rather thanSession
.Generally you want to write your own queries as queries have a minimal level of complexity.
But specific JPA/Hibernate methods don't allow to perform this kind of queries.
These methods handle only simple cases.So as a general rule, you should favor specific JPA/Hibernate methods over custom query creating at each time you may.
It is often a shortcut to avoid writing boiler plate code with JPQL.
For example if you want to retrieve a entity from its ID, you don't have any value to write at hand a so simple query.
You will have to write boiler plate code (creating query, setting parameter query, executing query).
UsingEntityManager.find(Class<T>, Object)
is a much simpler and also clearer approach as you don't need to go further to understand the behavior.Note that Spring Data JPA goes still further by providing more methods to handle other classic queries.
The SimpleJpaRepository class is a good example.At last, note that in some cases, specific JPA/Hibernate methods to manipulate entities are not a choice.
The operations related to the entities or theEntityManager
state can be performed only with these methods (persist()
,flush()
orrefresh()
,clear()
, ...).
相关问答
更多-
Hibernate继承hql类型(Hibernate inheritance hql type)[2024-03-07]
首先 - >我假设你使用了一个hibernate继承策略。 查询“来自用户”确实进行了休眠,不允许神奇地知道您只搜索客户。 您必须更改查询或整体机制。 示例解决方案 public class UserDaoImplextends BaseDaoImpl implements UserDao ,BaseDao { protected Class entityClass; public UserDaoImpl(Class enti ... -
我主要喜欢Criteria Queries来进行动态查询。 例如,根据一些参数,动态添加一些顺序或者留下一些部分(例如限制)更容易。 另一方面,我使用HQL进行静态和复杂的查询,因为它更易于理解/读取HQL。 另外,HQL有点强大,我想,例如对于不同的连接类型。 I mostly prefer Criteria Queries for dynamic queries. For example it is much easier to add some ordering dynamically or leav ...
-
即使Hibernate是最常用的JPA实现,我也会坚持使用规范API(JPA)。 所以EntityManager而不是Session 。 通常,您想编写自己的查询,因为查询具有最低程度的复杂性。 但特定的JPA / Hibernate方法不允许执行这种查询。 这些方法只处理简单的情况。 因此,作为一般规则,您应该在每次可能时都支持特定的JPA / Hibernate方法而不是自定义查询创建。 通常是避免使用JPQL编写boiler plate代码的捷径。 例如,如果你想从它的ID中检索一个实体,那么你没有任 ...
-
HQL Hibernate很多表(HQL Hibernate many tables)[2022-07-17]
首先你的问题没有完全清除,首先在这里定义你的数据库模型,并从你的查询我已经知道 hql.append(" DOC.id, "); 这里不会添加最后一个Coma hql.append(“DOC.id”); 这里 hql.append(" FROM ").append(DocumentoAssinanteTO.class.getName()).append(" DA "); 你不需要通过调用class.getname()方法来获取类的名称,你只需要在这里调用bean或bean的名称。 你的内部联接中存在 ... -
HQL Hibernate命令(HQL Hibernate order by)[2023-05-24]
您可以添加该客户类,如{c},并使用.addEntity('c',Customer.class),然后使用c.last_name的订单。 并建立客户与ProductDelivery的关系 you can add that customer class like {c} and use .addEntity('c', Customer.class) and then use the order by c.last_name. and make the relation of the Customer and ... -
不要连接HQL查询。 请改用命名参数 。 它是Hibernate中查询对象模式的一种实现。 对于你的情况: Session session = sessionFactory.getCurrentSession(); String selectQuery = "FROM Account as account WHERE account.username = :usernameParam"; Query query = session.createQuery(selectQuery); query.setPar ...
-
试试这个查询: from Report where reportId = :reportId order by version desc with setMaxResults = 1 Try this query: from Report where reportId = :reportId order by version desc with setMaxResults=1
-
iReport,使用SQL代替HQL查询与Hibernate连接(iReport, use SQL instead HQL query with an hibernate connection)[2023-11-23]
使用视图。 请参阅: Hibernate Union替代方案 Use a View. See this: Hibernate Union alternatives -
看起来您正在使用二级缓存。 如果是这样,这也行不通。 select o from ObjectDao o where o.objectType.client.name = :clientName Looks like you are using Level 2 cache. If so this will not work either. select o from ObjectDao o where o.objectType.client.name = :clientName
-
您的查询告诉数据库对满足WHERE子句的所有记录进行排序。 它有可能在返回前50之前对数百万条记录进行排序。 编辑1/26:现在澄清了具体问题,我将尝试更具体地回答。 每次执行这样的查询时,Hibernate都会进入数据库。 更重要的是,它会将会话中的所有新/更新数据刷新到磁盘。 如果这是您的情况,此行为可能会导致缓慢。 使用Hibernate查询API通常在大多数情况下都能很好地运行,并且与各种各样的数据库平台兼容。 如果您真的担心从数据访问层中挤出最后一滴性能,您可以编写自己的本机SQL查询来选择前50 ...