Brijesh Verma

Greenhorn
+ Follow
since Apr 20, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
1
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Brijesh Verma

Tim Holloway wrote:You can make your sample code and XML more readable if you use the Code button in our message editor.

This is the JSF forum and you want JPA (ORM) help. I'm moving this thread over there where you will find people who are more knowledgable on the topic.

For the record, however, I can personally attest that Envers works very well when using JPA in a JSF-based web application.



thanks for reply.

I have already tried all ways to run it

Can you provide me sample code for enver configuration.

so I can work on it.

Hello guys,

I am using hibernate envers with JPA set up.
My build is working fine after all setup and configuration.
but hibernate envers is not creating audit tables .
Please help me.

please find the below configuration for hibernate envers

1. <dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-envers</artifactId>
<version>3.6.4.Final</version>
</dependency>


2. Entity class

2. persistence.xml

3.
Hello guys,

I am using hibernate envers with JPA set up.

Please help me.

below is my configuration

1. <dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-envers</artifactId>
<version>3.6.4.Final</version>
</dependency>


2. Entity class


@Validated
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
@Entity
@Table(name = "PARTNER")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Audited
public class Partner extends AbstractBaseEntity<Long> {
public Partner() {


}

2. persistence.xml

<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="cnsapp" transaction-type="RESOURCE_LOCAL">

<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>com.app.cnt.partner.entity.Partner</class>
<class>com.app.cnt.customer.entity.Customer</class>


<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>

<property name="hibernate.hbm2ddl.auto" value="create"/>
<property name="hibernate.show_sql" value="true"/>

<property name="hibernate.ejb.event.post-insert"
value="org.hibernate.ejb.event.EJB3PostInsertEventListener,org.hibernate.envers.event.AuditEventListener" />
<property name="hibernate.ejb.event.post-update"
value="org.hibernate.ejb.event.EJB3PostUpdateEventListener,org.hibernate.envers.event.AuditEventListener" />
<property name="hibernate.ejb.event.post-delete"
value="org.hibernate.ejb.event.EJB3PostDeleteEventListener,org.hibernate.envers.event.AuditEventListener" />
<property name="hibernate.ejb.event.pre-collection-update"
value="org.hibernate.envers.event.AuditEventListener" />
<property name="hibernate.ejb.event.pre-collection-remove"
value="org.hibernate.envers.event.AuditEventListener" />
<property name="hibernate.ejb.event.post-collection-recreate"
value="org.hibernate.envers.event.AuditEventListener" />

<property name="org.hibernate.envers.audit_table_suffix"
value="_AUD" />
<property name="org.hibernate.envers.revision_field_name"
value="REV" />
<property name="org.hibernate.envers.revision_type_field_name"
value="REVTYPE" />
<property name="org.hibernate.envers.default_schema"
value="toshibaschema" />
<property name="org.hibernate.envers.revision_on_collection_change"
value="false" />


</properties>
</persistence-unit>
</persistence>

3.
<!-- Entity manager Factory -->
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
>
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="com.app.cnt.*" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" >
<property name="generateDdl" value="true" />
<property name="showSql" value="true" />
</bean>
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.hbm2ddl.auto">create</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.temp.use_jdbc_metadata_defaults">false</prop>

<!-- <prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory
</prop> -->
<prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory
</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.cache.use_second_level_cache">true</prop>

<prop key="org.hibernate.envers.auditTablePrefix"></prop>
<prop key="org.hibernate.envers.auditTableSuffix">_AUD</prop>
</props>
</property>

<property name="persistenceUnitName" value="cnsapp" />
<property name="loadTimeWeaver">
<bean class="org.springframework.instrument.classloading.InstrumentationLoadTimeWeaver"/>
</property>

you have to call client object from you jsf handler class and return type is ClientResponse<Users> in your client class

Remember Users class is not your domain class . it is your bean class which you have create because web service does not understand List<User>

So follow these steps
UserHandler class


@Controller("userHandler")
@Scope("session")
public class UserHandler implements Serializable {

@Resource
private UserClient userClient;

private List<User> users;

public Collection<User> getUsers() {
if (users == null) {

users = userClient.getUsers().getEntity().getUsers();

}
return users;
}

And use this bean class in your client class for return type

@XmlRootElement
public class Users {


private List<User> users = new ArrayList<User>();


public Users() {
}

public Users(List<User> users) {
this.users = users;
}


@XmlElement(name = "user")
public List<User> getUsers() {
return users;
}


public void setUsers(List<User> users) {
this.users = users;
}
}


12 years ago
JSF
Thanks guys

Its happen because of your helpful information and guidelines
12 years ago
there are two steps

just create interface class and map logical url to resource class

@Path(EmployeeResource.EMP_URL)

interface EmployeeClient{

@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("all")
public ClientResponse<Employee> getEmployeeDetails();

}


@Path( EmployeeResource.EMP_URL)
class EmployeeResource{
public static final String EMP_URL = "/service/employee";

@Autowired
EmployeeService. employeeService.;


@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("all")
public Employee getEmployeeDetails(){

return employeeService.getEmployee();

}

finally initialize client in resteasy.xml


now you can use client directly in jsf handler class


12 years ago
JSF
finally I cleared SCEA exam with 93%
12 years ago
At last Cleared SCDJWS with 91 %
12 years ago
because your using super class reference to call eat() method and at complile time compiler will call Animal method
which is throwing Exception so all Checked Exception should be in enclosed in try/catch block

Example

if you throw checked exception then you will get an error at compile time

import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;


public class InterfaceTest {

public static void main(String[] args) {


InterfaceTest a = new A();

a.add();
}

void add() throws IOException
{

}

}

class A extends InterfaceTest
{
void add(){


}

}

if you throw unchecked/runtime exception then you will not get an error at compile time

ublic class InterfaceTest {

public static void main(String[] args) {


InterfaceTest a = new A();

a.add();
}

void add() throws ArrayIndexOutOfBoundsException
{

}

}

class A extends InterfaceTest
{
void add(){


}

}
14 years ago
Java 1.5 features
--------------------
1.Enhanced for loop(for each for loop).
2.Enumeration( enum keyword)
3.Assertions added in java 1.5
4.AutoBoxing/Unboxing ( like wrapper classes . means automatic convert between primitive to String and vice-versa.)
5.Generics ( example: typed Collections, Set(<String>))
6.Varagrs (variable arguments) (example : for printf() function,allows variable number of different arguments)
7.StringBuilder class in jdk 1.5 (java.lang package)
8.Annotations.







See More









JDK 1.0 (january 23, 1996) oak
- Initial release


JDK 1.1 (february 19, 1997)
- Retooling of the AWT event model
- Inner classes added to the language
- JavaBeans
- JDBC
- RMI


J2SE 1.2 (December 8, 1998) playground
This and subsequent releases through J2SE 5.0 were rebranded retrospectively Java 2 & version name "J2SE"
(Java 2 platform, Standard edition) replaced JDK to distinguish the base platform from
J2EE (java 2 platform, enterprise edition) and J2ME (java 2 platform, micro edition).

- Strictfp keyword
- Reflection
- Swing api integration into the core classes
- JVM equipped with a jit compiler
- Java plug-in
- Java IDL
- An IDL implementation for corba interoperability
- Collections Framework


J2SE 1.3 (may 8, 2000) kestrel
- Hotspot jvm included
- JavaSound
- JNDI included in core libraries
- Java platform debugger architecture (jpda)
- RMI was modified to support optional compatibility with corba


J2SE 1.4 (february 6, 2002) merlin
- assert keyword
- Regular expressions
- Exception chaining (allows an exception to encapsulate original lower-level exception)
- Internet protocol version 6 (IPV6) support
- Non-blocking nio (new input/output)
- Logging API
- Image i/o api for reading and writing images in formats like jpeg and png
- Integrated XML parser and XSLT processor (JAXP)
- Integrated security and cryptography extensions (JCE, JSSE, JAAS)
- Java web start


J2SE 5.0 (september 30, 2004) tiger [originally numbered 1.5]
- Generics: provides compile-time (static) type safety for collections and eliminates the need for most typecasts (type conversion).
- Metadata: also called annotations; allows language constructs such as classes and methods to be tagged with additional data, which can then be processed by metadata-aware utilities.
- Autoboxing/unboxing: automatic conversions between primitive types (such as int) and primitive wrapper classes (such as integer).
- Enumerations: the enum keyword creates a typesafe, ordered list of values (such as day.monday, day.tuesday, etc.). Previously this could only be achieved by non-typesafe constant integers or manually constructed classes (typesafe enum pattern).
- Swing: new skinnable look and feel, called synth.
- Var args: the last parameter of a method can now be declared using a type name followed by three dots (e.g. Void drawtext(string... Lines)). In the calling code any number of parameters of that type can be used and they are then placed in an array to be passed to the method, or alternatively the calling code can pass an array of that type.
- Enhanced for each loop: the for loop syntax is extended with special syntax for iterating over each member of either an array or any iterable, such as the standard collection classesfix the previously broken semantics of the java memory model, which defines how threads interact through memory.
- Automatic stub generation for rmi objects.
- Static imports concurrency utilities in package java.util.concurrent.
- Scanner class for parsing data from various input streams and buffers.
- Assertions
- StringBuilder class (in java.lang package)
- Annotations



Java SE 6 (december 11, 2006) mustang
sun replaced the name "J2SE" with java se and dropped the ".0" from the version number.
Beta versions were released in february and june 2006, leading up to a final release that occurred on december 11, 2006.
The current revision is update 14 which was released in may 2009.

- Support for older win9x versions dropped.
- Scripting lang support: Generic API for integration with scripting languages, & built-in mozilla javascript rhino integration
- Dramatic performance improvements for the core platform, and swing.
- Improved web service support through JAX-WS JDBC 4.0 support
- Java compiler API: an API allowing a java program to select and invoke a java compiler programmatically.
- Upgrade of JAXB to version 2.0: including integration of a stax parser.
- Support for pluggable annotations
- Many GUI improvements, such as integration of swingworker in the API, table sorting and filtering, and true swing double-buffering (eliminating the gray-area effect).


Java se 6 update 10
A major enhancement in terms of end-user usability.
- Java Deployment Toolkit, a set of javascript functions to ease the deployment of applets and java web start applications.
- Java Kernel, a small installer including only the most commonly used jre classes. Enhanced updater.
- Enhanced versioning and pack200 support: server-side support is no longer required.
- Java quick starter, to improve cold start-up time.
- Improved performance of java2D graphics primitives on windows, using direct3D and hardware acceleration.
- A new Swing look and feel called NIMBUS and based on synth.
- Next-generation java plug-in: applets now run in a separate process and support many features of web start applications.


Java se 6 update 12
This release includes the highly anticipated 64-bit java plug-in (for 64-bit browsers only), windows server 2008 support,
and performance improvements of java and JAVAFX applications.



14 years ago
Hi Guys ..

at last i cleard SCBCD 5.0 with good score...

14 years ago
Hi guys,

hope you all doing well

last week i have completed SCBCD 5.0 and now i am thing about SOA or SCEA part 1.


but i have confusion shall i go for SOA or SCEA , can anyone suggest that what are benifit of SOA over SCEA certification..
Hi Roopa,
can you tell me which books refered for SCWCD preperation and how many months took for this preperation
and any good suggestion for good score
because this month i am planing for exam.
14 years ago
do one thing put all Employee object in list object and

call this methos Collections.sort(listObject); in that class where you want sorting

put this in Employee class

public int compareTo(Object o) {
Employee e = (Employee ) o;
return this.id.compareToIgnoreCase(e.getId());

}

14 years ago
i think you know this
. . fedcba
01234567

1. class Polish {
2. public static void main(String[] args) {
3. int x = 4 ;
4. StringBuffer sb = new StringBuffer("..fedcba");
5. sb.delete(3,6); // deletes "edc" from index 3 (zero-based) to position 6 (one-based ) means till 5th position
6. sb.insert(3, "az"); // insert "az" after the f character; because f is on 2 position
7. if(sb.length() > 6) x = sb.indexOf("b"); // now string is ..fazba index equals 5 (zero-based)
8. sb.delete((x-3), (x-2)); // sb.delete(2,3) deletes the f character .because it is on 2nd position
9. System.out.println(sb);
10. } }