Function to fix a sequence in oracle

If someone inserted some rows not using sequence and you have to increase the sequence value to use it again, here’s a procedure for it :

WARNING: the procedure assumes that the field that contains value generated through sequence is called ID!

create procedure move_sequence(sequence_name varchar2, table_name varchar2)

is
  przesuniecie number(19,0);
  max_id number(19,0);
  sequence_value number(19,0);
begin
  execute immediate 'select max(id) from ' || table_name into max_id;
  execute immediate 'select ' || sequence_name || '.nextval from dual' into sequence_value;
  
  execute immediate 'ALTER SEQUENCE ' || sequence_name || ' INCREMENT BY ' || (max_id - sequence_value + 1);
  execute immediate 'select ' || sequence_name || '.nextval from dual' into sequence_value;
  
  execute immediate 'ALTER SEQUENCE ' || sequence_name || ' INCREMENT BY ' || 1;
  
end;
/

Spring: filtering component scan

To narrow resources to be scanned:

<context:component-scan base-package="com.mszynkiewicz.app">
      <context:include-filter type="regex" expression="com\.mszynkiewicz\.app\.included1.*"/>
      <context:include-filter type="regex" expression="com\.mszynkiewicz\.app\.included2.*"/>
      <context:exclude-filter type="regex" expression="com\.mszynkiewicz\.app\.excluded"/>
      <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
      <!-- todo: check if it can be a custom annotation
      <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
      -->
</context:component-scan>

JBoss: Isolating classloaders for all ears

At the bottom of deployers/ear-deployer-jboss-beans.xml change:

<bean name="EARClassLoaderDeployer" class="org.jboss.deployment.EarClassLoaderDeployer">
      <!-- A flag indicating if ear deployments should have their own scoped
      class loader to isolate their classes from other deployments.
      -->
      <property name="isolated">false</property>
</bean>

to:

<bean name="EARClassLoaderDeployer" class="org.jboss.deployment.EarClassLoaderDeployer">
      <!-- A flag indicating if ear deployments should have their own scoped
      class loader to isolate their classes from other deployments.
      -->
      <property name="isolated">true</property>
</bean>