[Beginners Corner] - Encoding in Hypersonic database
by dapissarenko
Hello!
I want to use JBoss with Hypersonic Database.
I've created a couple of JSP pages and servlets, using which the user can enter data into the database via EJBs with container-managed persistence.
Some of the web pages are used for entering string data into the database.
It works fine as long as the string are US English.
However, when I try to enter Cyrillic or German characters, a problem occurs. When those strings are read from the database, they are displayed incorrectly (both Cyrillic letters and German umlauts).
All web pages have UTF-8 encoding, which is set in the header:
<?xml version="1.0" encoding="UTF-8" ?>
I would like to know where and how I can configure the encoding of the database.
TIA
Dmitri Pissarenko
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3961595#3961595
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3961595
19 years, 9 months
[EJB 3.0] - How to store information about many-to-many relationship its
by dbatcn
I have a situation where I have a many-to-many bidirectional relationship between two entity beans "User" and "Group", where users can belong to many groups and groups can have many users. I want to keep track of the status of the relationship itself and still take advantage of automatic table generation from source annotations in a database-independent fashion. For example, a user's status in a group could be "invited" or "member" independently for each group that the user is related to. The user is the owning side of the relation, although that doesn't seem relevant to me. It seems to me that what I want to do is have another column in the join table and I'm stumped about how to do in a clean way and was unable to find anything about this topic; I've read Bill Burke's O'Reilly EJB3 book and couldn't think of good search terms that would capture this issue. (I'm also using Seam, although I don't think that's germane here.) I imagine I could hack in another column to the join table with an ALTER TABLE, but that strikes me as a kluge and I don't see how I could easily deal with group member status using EJB3. Does anybody have a suggestion? Pointers on how to do this or to previous discussions of this topic gratefully accepted.
current Group.java
| ...
| @Entity
| @Table(name="GROUPS")
| public class Group implements Serializable {
|
| private long id;
| private Set<User> users = new HashSet<User>();
|
| @Id
| @Column(name="GROUP_ID")
| @GeneratedValue
| public Long getId() {
| return id;
| }
| public void setId(Long id) {
| this.id = id;
| }
|
| @ManyToMany(cascade=CascadeType.PERSIST,mappedBy="groups")
| public Set<User> getUsers() {
| return users;
| }
| public void setUsers( Set<User> users ) {
| this.users = users;
| }
|
| ...
| }
|
current User.java
| ...
| @Entity
| @Table(name="USERS")
| public class User implements Serializable {
|
| private long id;
| private Set<Group> groups = new HashSet<Group>();
|
| @Id
| @Column(name="USER_ID")
| @GeneratedValue
| public Long getId() {
| return id;
| }
| public void setId(Long id) {
| this.id = id;
| }
|
| @ManyToMany(cascade=CascadeType.PERSIST)
| @JoinTable(name="USER_GROUP",
| joinColumns={@JoinColumn(name="USER_ID")},
| inverseJoinColumns={@JoinColumn(name="GROUP_ID")})
| public Set<Group> getGroups() {
| return groups;
| }
| public void setGroups( Set<Group> groups ) {
| this.groups = groups;
| }
|
| ...
| }
|
currently generated schema:
anonymous wrote :
| 2006-07-27 19:15:53,790 DEBUG [org.hibernate.tool.hbm2ddl.SchemaExport] create table GROUPS (GROUP_ID bigint generated by default as identity (start with 1), ..., primary key (GROUP_ID))
| 2006-07-27 19:15:53,790 DEBUG [org.hibernate.tool.hbm2ddl.SchemaExport] create table USERS (USER_ID bigint generated by default as identity (start with 1), ..., primary key (USER_ID))
| 2006-07-27 19:15:53,790 DEBUG [org.hibernate.tool.hbm2ddl.SchemaExport] create table USER_GROUP (USER_ID bigint not null, GROUP_ID bigint not null, primary key (USER_ID, GROUP_ID))
| 2006-07-27 19:15:53,790 DEBUG [org.hibernate.tool.hbm2ddl.SchemaExport] alter table USER_GROUP add constraint FKC62E00EB21CA0D09 foreign key (USER_ID) references USERS
| 2006-07-27 19:15:53,790 DEBUG [org.hibernate.tool.hbm2ddl.SchemaExport] alter table USER_GROUP add constraint FKC62E00EB44BDA00B foreign key (GROUP_ID) references GROUPS
|
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3961593#3961593
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3961593
19 years, 9 months
[Persistence, JBoss/CMP, Hibernate, Database] - Manually having flush session
by smithbstl
I am working with JBOSS 4.0.4GA and Hibernate 3.1.3
I am attempting to manipulate a record in Oracle. For some reason, I am having to manually flush the session to get the changes to show up in the database. From the documentation I have read, I should not have to flush the session as long as I call commit() on the transaction.
I am using Hibernate as a MBean Service in JBOSS with har deployment.
Here is my code
public void delete(int acctId){
| Session session = null;
| Transaction tx = null;
| try {
| session = ServiceLocator.getHibernateSession(HIBERNATE_SESSION_FACTORY);
| tx = session.beginTransaction();
| AccountBean acctBean = (AccountBean) session.get(AccountBean.class,acctId);
| //For debugging
| if (acctBean == null) {
| System.out.println("AccountBean = Null");
| } else {
| System.out.println("AccountDelete");
| System.out.println("-AcctID = " + acctBean.getAcctId());
| System.out.println("-AcctNum = " + acctBean.getAcctNum());
| System.out.println("-AcctName = " + acctBean.getAcctName());
| }
| session.delete(acctBean);
| tx.commit();
| } catch (Exception e) {
| try {
| tx.rollback();
| } catch (Exception e2) {
| System.out.println(e2);
| }
| System.out.println(e);
| } finally {
| try {
| if (session != null) {
| //Why do I need to call flush here?
| session.flush();
| session.close();
| }
| } catch (Exception e) {
| System.out.println(e);
| }
| }
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3961592#3961592
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3961592
19 years, 9 months
[Security & JAAS/JBoss] - sessionDestroyed && home.create
by polymedes
I've got a problem logging out the currently logged on user. I have a javax.servlet.http.HttpSessionListener in my web application, declared as
<listener-class>my.SessionCounter</listener-class>
in web.xml
Inside the sessionDestroyed event handler I call this code:
public void sessionDestroyed(HttpSessionEvent se) {
if (activeSessions > 0)
activeSessions--;
try {
MyServiceLocal iface = BeanLocator.getInstance().getMyService();
if (iface!=null)
iface.logoutCurrentUser( (String)se.getSession().getAttribute("my.current.user") );
} catch (Exception ex) {
System.out.println("XTYPHSE PALI TO MPOYRDELO! " + ex.getClass().getName());
}
}
I have an error "javax.ejb.AccessLocalException" in the line:
MyServiceLocal iface = BeanLocator.getInstance().getMyService();
The error fires when home.create() is called:
public MyServiceLocal getMyService() {
try {
home = (MyServiceLocalHome) ctx.lookup("my.jndiName");
//home is ok here, but calling create() will throw an AccessLocalException
return home.create();
} catch (...) {...}
}
The interface for the bean "MyService" is generated with option @ejb.permission view-type="all" unchecked="true"
The security domain is defined ("myApp" in jboss-web.xml and in jboss.xml)
My login-config.xml contains the following:
<application-policy name = "myApp">
<login-module code = "my.login.MyLoginModule" flag = "required">
<module-option name="unauthenticatedIdentity">nobody</module-option>
</login-module>
<!-- Add this line to your login-config.xml to include the ClientLoginModule propogation -->
<login-module code="org.jboss.security.ClientLoginModule" flag="required">
<module-option name="unauthenticatedIdentity">nobody</module-option>
</login-module>
</application-policy>
What is the problem? How can I logout the user (ie mark the user "clean" in the database), ON session destroy?
Any help will be much appreciated
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3961588#3961588
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3961588
19 years, 9 months